[Python-Dev] Python startup optimization: script vs. service (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Mon Oct 2 11:38:42 EDT 2017
- Previous message (by thread): [Python-Dev] Python startup optimization: script vs. service
- Next message (by thread): [Python-Dev] Python startup optimization: script vs. service
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
02.10.17 16:26, Victor Stinner пише:
While "import module" is fast, maybe we should use sometimes a global variable to cache the import.
module = None def func(): global module if module is None: import module ...
I optimized "import module", and I think it can be optimized even more, up to making the above trick unnecessary. Currently there is an overhead of checking that the module found in sys.modules is not imported right now.
- Previous message (by thread): [Python-Dev] Python startup optimization: script vs. service
- Next message (by thread): [Python-Dev] Python startup optimization: script vs. service
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]