[issue25856] The __module__ attribute of non-heap classes is not interned
Serhiy Storchaka
report at bugs.python.org
Tue Dec 29 02:43:41 EST 2015
Serhiy Storchaka added the comment:
Interning the __module__ string causes small performance hit:
$ ./python -m timeit -s "from itertools import chain" -- "chain.__module__; chain.__module__; chain.__module__; chain.__module__; chain.__module__; chain.__module__; chain.__module__; chain.__module__; chain.__module__; chain.__module__"
Unpatched: 1.93 usec per loop
Patched: 4.09 usec per loop
This can be avoided if cache created string in type's __dict__. Following patch makes __module__ retrieving for non-heap types as fast as for heap types:
Patched2: 0.871 usec per loop
----------
type: performance -> enhancement
Added file: http://bugs.python.org/file41443/intern_and_cache___module__.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25856>
_______________________________________
More information about the Python-bugs-list
mailing list