[issue22557] Local import is too slow

2016-08-06 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue22557] Local import is too slow

2016-08-02 Thread Roundup Robot
Roundup Robot added the comment: New changeset 64f195790a3a by Serhiy Storchaka in branch 'default': Issue #22557: Now importing already imported modules is up to 2.5 times faster. https://hg.python.org/cpython/rev/64f195790a3a -- nosy: +python-dev

[issue22557] Local import is too slow

2016-08-02 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you for your review Brett. -- assignee: -> serhiy.storchaka ___ Python tracker ___

[issue22557] Local import is too slow

2016-07-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Seems not all such easy. Looking in sys.module is not enough, we should check __spec__._initializing. Following patch moves optimizations to PyImport_ImportModuleLevelObject (C implementation of standard __import__). Main optimizations: 1.

[issue22557] Local import is too slow

2016-06-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: faster_import_pkg.patch optimizes also an import of names with dots. $ ./python -m timeit 'import os.path' Unpatched:10 loops, best of 3: 2.08 usec per loop faster_import_5.patch:100 loops, best of 3: 1.79 usec per loop

[issue22557] Local import is too slow

2016-06-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thanks Victor. -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue22557] Local import is too slow

2016-06-20 Thread STINNER Victor
STINNER Victor added the comment: I rebased faster_import_4.patch on default. -- Added file: http://bugs.python.org/file43491/faster_import_4.patch ___ Python tracker

[issue22557] Local import is too slow

2016-06-20 Thread STINNER Victor
STINNER Victor added the comment: > Do you happen to know why you didn't get a review link for your patch, Serhiy? faster_import_4.patch is based on the revision d736c9490333 which is not part of the CPython repository. -- nosy: +haypo ___ Python

[issue22557] Local import is too slow

2016-06-20 Thread Brett Cannon
Brett Cannon added the comment: Do you happen to know why you didn't get a review link for your patch, Serhiy? -- ___ Python tracker ___

[issue22557] Local import is too slow

2016-06-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Fixed bugs making test_importlib failing. Microbenchmark results on faster machine: $ ./python -m timeit 'import locale' Unpatched: 100 loops, best of 3: 0.839 usec per loop Patched:1000 loops, best of 3: 0.176 usec per loop $ ./python -m

[issue22557] Local import is too slow

2014-10-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Yes, my CPU is slow. Here is a patch which factors out IMPORT_NAME into a separate import_name() function and adds optimization for more general case when __import__ is not overloaded. -- Added file:

[issue22557] Local import is too slow

2014-10-10 Thread Antoine Pitrou
Antoine Pitrou added the comment: The issue is local imports, not imports of the locale module :-) -- title: Locale import is too slow - Local import is too slow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22557

[issue22557] Local import is too slow

2014-10-05 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- title: Locale import is too slow - Local import is too slow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22557 ___

[issue22557] Local import is too slow

2014-10-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: This would sound reasonable to me, but I wonder if it may change behaviour with weird custom __import__ overrides. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22557

[issue22557] Local import is too slow

2014-10-05 Thread Nick Coghlan
Nick Coghlan added the comment: __import__ is intended as an absolute override (including of the sys.modules cache lookup), so we can't bypass it without breaking backwards compatibility. It's possible there is room for other optimisations that don't break the import override semantics (such

[issue22557] Local import is too slow

2014-10-05 Thread Eric V. Smith
Changes by Eric V. Smith e...@trueblade.com: -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22557 ___ ___ Python-bugs-list

[issue22557] Local import is too slow

2014-10-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm not experienced in import machinery. Here is preliminary patch which implements my idea for particular case. Performance effect is almost so good as manual caching in a global. import timeit def f(): ... import locale ... min(timeit.repeat(f,

[issue22557] Local import is too slow

2014-10-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Second version of the patch uses fast patch only when builtin __import__ is not overridden. It is slightly slower (due to lookup of __import__). import timeit def f(): ... import locale ... min(timeit.repeat(f, number=10, repeat=10))

[issue22557] Local import is too slow

2014-10-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: I would suggest factoring out IMPORT_NAME into a separate import_name() function, like is already one for import_from(). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22557

[issue22557] Local import is too slow

2014-10-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: Some more general comments about this: - Let's keep in mind the absolute numbers. 0.450120013341 for 10 iterations is 4.5ms per iteration. This is not very slow by CPython's standards. - I wonder if you ran your benchmark in debug mode or if your CPU