[issue28216] micro optimization for import_all_from

2016-09-20 Thread Xiang Zhang

Xiang Zhang added the comment:

As pointed out by Serhiy, PyObject_GetAttr may change __all__ so my proposal is 
not going to work. Close this and sorry for noise. :-(

--
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28216] micro optimization for import_all_from

2016-09-20 Thread Xiang Zhang

New submission from Xiang Zhang:

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 
*", "", "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 *", "", "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 
*", "", "exec")' 'exec(code)'

Median +- std dev: 12.5 us +- 0.3 us
./python3 -m perf timeit -s 'import zipfile; code=compile("from zipfile import 
*", "", "exec")' 'exec(code)'

Median +- std dev: 3.09 us +- 0.06 us

--
components: Interpreter Core
files: import_all_from.patch
keywords: patch
messages: 277046
nosy: brett.cannon, haypo, serhiy.storchaka, xiang.zhang
priority: normal
severity: normal
stage: patch review
status: open
title: micro optimization for import_all_from
type: enhancement
versions: Python 3.7
Added file: http://bugs.python.org/file44758/import_all_from.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com