ZODB Components: Optimize find_load_module() from b45914fa ExternalMethod optimization.
This method is used to import ZODB Components when fallback on filesystem is needed and used when loading Document and Extension Components. 1,000,000 executions: * Before: timeit("erp5.component.extension.find_load_module(module_name)", setup="import erp5.component.extension; module_name='Hoge'") 59.073 59.324 * b45914fa ExternalMethod optimization: timeit("__import__('erp5.component.extension.' + module_name, fromlist='*', level=0)", setup="module_name='Hoge'") 1.754 1.845 * This commit: timeit("import_module('erp5.component.extension.' + module_name)", setup="from importlib import import_module; module_name='Hoge'") 1.346 1.311 => Faster because import_module() calls __import__() without fromlist (not needed as it returns module from sys.modules after this) and level parameters. => Introduced in python3 and backported to python2.7. Recommended over __import__ in Python documentation for non-internal usage and when getting the module itself and not its top-level one.
Showing
Please register or sign in to comment