This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xiang.zhang
Recipients brett.cannon, serhiy.storchaka, vstinner, xiang.zhang
Date 2016-09-20.17:06:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1474391200.85.0.926486435821.issue28216@psf.upfronthosting.co.za>
In-reply-to
Content
Since PyMapping_Keys always return a list or tuple and most __all__s are list (all in stdlib), I think we can avoid calling PySequence_GetItem for every key and use PySequence_Fast* APIs instead. This doesn't help much since other operations involved are expensive.

With patch:

[bin]$ ./python3 -m perf timeit -s 'import _ast; code=compile("from _ast import *", "<string>", "exec")' 'exec(code)'
....................
Median +- std dev: 11.3 us +- 0.3 us
[bin]$ ./python3 -m perf timeit -s 'import zipfile; code=compile("from zipfile import *", "<string>", "exec")' 'exec(code)'
....................
Median +- std dev: 2.98 us +- 0.04 us

Without patch:

[bin]$ ./python3 -m perf timeit -s 'import _ast; code=compile("from _ast import *", "<string>", "exec")' 'exec(code)'
....................
Median +- std dev: 12.5 us +- 0.3 us
./python3 -m perf timeit -s 'import zipfile; code=compile("from zipfile import *", "<string>", "exec")' 'exec(code)'
....................
Median +- std dev: 3.09 us +- 0.06 us
History
Date User Action Args
2016-09-20 17:06:40xiang.zhangsetrecipients: + xiang.zhang, brett.cannon, vstinner, serhiy.storchaka
2016-09-20 17:06:40xiang.zhangsetmessageid: <1474391200.85.0.926486435821.issue28216@psf.upfronthosting.co.za>
2016-09-20 17:06:40xiang.zhanglinkissue28216 messages
2016-09-20 17:06:40xiang.zhangcreate