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 serhiy.storchaka
Recipients brett.cannon, eric.smith, eric.snow, ncoghlan, pitrou, serhiy.storchaka
Date 2014-10-05.14:26:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <3302796.27zqVUnYJV@raxxla>
In-reply-to <1412512748.14.0.876603717349.issue22557@psf.upfronthosting.co.za>
Content
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, number=100000, repeat=10))
0.09563599999819417

Of course it breaks tests.

> It's possible there is room for other optimisations that don't break the
> import override semantics (such as a fast path for when __import__ is the
> standard import function).

Good idea.
Files
File name Uploaded
faster_import.patch serhiy.storchaka, 2014-10-05.14:26:33
History
Date User Action Args
2014-10-05 14:26:34serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, ncoghlan, pitrou, eric.smith, eric.snow
2014-10-05 14:26:34serhiy.storchakalinkissue22557 messages
2014-10-05 14:26:34serhiy.storchakacreate