[New-bugs-announce] [issue32946] Speed up import from non-packages

Serhiy Storchaka report at bugs.python.org
Sun Feb 25 03:46:54 EST 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

The proposed PR optimizes "from ... import ..." from non-package modules.

$ ./python -m perf timeit 'from locale import getlocale'
Unpatched:  Mean +- std dev: 811 ns +- 27 ns
Patched:    Mean +- std dev: 624 ns +- 17 ns

Currently _bootstrap._handle_fromlist() is called which does nothing if the module is not a package, but adds an overhead of calling a Python function. The PR moves this check out of _handle_fromlist and avoid calling it if not needed.

----------
components: Interpreter Core
messages: 312781
nosy: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Speed up import from non-packages
type: performance
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32946>
_______________________________________


More information about the New-bugs-announce mailing list