Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] importlib quest

Antoine Pitrousolipsis at pitrou.net
Mon Feb 6 21:44:48 CET 2012


On Mon, 6 Feb 2012 20:49:48 +0100Antoine Pitrou <solipsis at pitrou.net> wrote:> On Mon, 6 Feb 2012 09:57:56 -0500> Brett Cannon <brett at python.org> wrote:> > Thanks for any help people can provide me on this now 5 year quest to get> > this work finished.>> Do you have any plan to solve the performance issue?>> $ ./python -m timeit -s "import sys; mod='struct'" \>   "__import__(mod); del sys.modules[mod]"> 10000 loops, best of 3: 75.3 usec per loop> $ ./python -m timeit -s "import sys; mod='struct'; from importlib import __import__" \>   "__import__(mod); del sys.modules[mod]"> 1000 loops, best of 3: 421 usec per loopThe culprit for the overhead is likely to be PathFinder.find_module:$ ./python -m timeit -s "import sys; mod='struct'; from importlib._bootstrap import _DefaultPathFinder; finder=_DefaultPathFinder" "finder.find_module('struct')"1000 loops, best of 3: 355 usec per loop$ ./python -S -m timeit -s "import sys; mod='struct'; from importlib._bootstrap import _DefaultPathFinder; finder=_DefaultPathFinder" "finder.find_module('struct')"10000 loops, best of 3: 176 usec per loopNote how it's dependent on sys.path length. On an installed Python withmany additional sys.path entries (e.g. because of distribute-basedmodule installs), import times will be much worse.RegardsAntoine.


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp