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 <rep...@bugs.python.org>
<http://bugs.python.org/issue25856>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to