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.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to