STINNER Victor added the comment: > Why not: > > try: > from _operator import * > except ImportError: > from _pyoperator import *
Let's try (I replaced operator.py with these 4 lines). $ ./python -m timeit "import sys; modname='operator'" "__import__(modname); del sys.modules[modname]; del sys.modules['_operator']" 10000 loops, best of 3: 165 usec per loop $ ./python -m timeit "import sys; modname='operator'" "__import__(modname); del sys.modules[modname]" 10000 loops, best of 3: 136 usec per loop "import operator" is only 2x faster (289 usec => 136 usec). It's less interesting. And what would be the purpose of a file of 4 line which containing "import *"? Do you think that PyPy, IronPython and Jython will reuse such trampoline/wrapper? ---------- type: -> performance _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19229> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com