New submission from Antoine Pitrou <[email protected]>:
This patch makes importlib's _FileFinder more than 10x faster by keeping a
cache of directory entries. It's actually faster than imp.find_module()!
-> imp.find_module:
$ ./python -m timeit -s "import imp" "imp.find_module('logging', None)"
10000 loops, best of 3: 69.9 usec per loop
$ ./python -m timeit -s "import imp" "imp.find_module('bisect', None)"
10000 loops, best of 3: 108 usec per loop
-> unpatched importlib:
$ ./python -m timeit -s "from importlib._bootstrap import _DefaultPathFinder as
Finder" "Finder.find_module('logging', None)"
1000 loops, best of 3: 431 usec per loop
$ ./python -m timeit -s "from importlib._bootstrap import _DefaultPathFinder as
Finder" "Finder.find_module('bisect', None)"
1000 loops, best of 3: 468 usec per loop
-> patched importlib:
$ ./python -m timeit -s "from importlib._bootstrap import _DefaultPathFinder as
Finder" "Finder.find_module('logging', None)"
10000 loops, best of 3: 37.5 usec per loop
$ ./python -m timeit -s "from importlib._bootstrap import _DefaultPathFinder as
Finder" "Finder.find_module('bisect', None)"
10000 loops, best of 3: 36.9 usec per loop
----------
components: Interpreter Core, Library (Lib)
files: find_module_cache.patch
keywords: patch
messages: 153566
nosy: brett.cannon, pitrou
priority: normal
severity: normal
stage: patch review
status: open
title: Speed-up importlib's _FileFinder
type: performance
versions: Python 3.3
Added file: http://bugs.python.org/file24547/find_module_cache.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue14043>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com