[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

STINNER Victor report at bugs.python.org
Mon Oct 28 22:18:28 CET 2013


STINNER Victor added the comment:

> Another option is to add a _pyoperator module.

Attached builtin_operator.patch patch implements this option: operator.c becomes the main operator module, _pyoperator is the pure Python implementation (don't use "from _operator import *" anymore).

With the patch:

$ ./python -m timeit "import sys; modname='_pyoperator'" "__import__(modname); del sys.modules[modname]" 
1000 loops, best of 3: 276 usec per loop

$ ./python -m timeit "import sys; modname='operator'" "__import__(modname); del sys.modules[modname]" 
10000 loops, best of 3: 22.7 usec per loop


The patch is huge because files are renamed: see builtin_operator_diff.patch for the diff.

----------
keywords: +patch
Added file: http://bugs.python.org/file32403/builtin_operator.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19229>
_______________________________________


More information about the Python-bugs-list mailing list