Answer the question
In order to leave comments, you need to log in
What is faster to import a local module or a global one?
there is a function from lodash that will be used in many parts of the application, for speed it would be better to make one import of the library into your function, and already use it throughout the application, or would it be acceptable to import the function itself from the library in all parts of the application?
Answer the question
In order to leave comments, you need to log in
It must be imported in those modules where it is needed. Modules in node.js are cached https://nodejs.org/api/modules.html#modules_caching
What's the point? At startup, all this is poured into memory, and does not constantly twitch from the disk, if the volume of modules is important, then in lodash you can connect only the necessary lodash / map functions (for example). You can also build the application and run it, but this is hardly necessary in the backend part.
It is necessary to remove the slashes and what is between them.Specify what exactly you want to get from the string
>>> filename='/home/user/develop/user/project/protatypes/Hatredcopter.mp3'
>>> if '/' in filename:
filename=filename[filename.rindex('/')+1:]
>>> filename
'Hatredcopter.mp3'
>>> import os
>>> filename='/home/user/develop/user/project/protatypes/Hatredcopter.mp3'
>>> os.path.split(filename)
('/home/user/develop/user/project/protatypes', 'Hatredcopter.mp3')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question