[Python-Dev] New and Improved Import Hooks
Moore, Paul
Paul.Moore@atosorigin.com
Tue, 3 Dec 2002 16:48:14 -0000
From: Just van Rossum [mailto:just@letterror.com]
> > I've explained this a couple of times now. Please read
> > the PEP for details, but Jim claims that zipfile imports
> > need this if they are not to be too slow.
> Well, I am not going to need it: upon reading the zip
> contents table I build a dict, mapping (full) module
> names to toc info. One dict lookup will be enough to
> get at the right data.
But that's exactly what Jim's cache is doing. His code is
general, and offers the service to *all* import methods,
rather than restricting it to only zipfiles. His benchmarks
showed that this was a (small) win.
Perhaps you could refactor your implementation so that the
cache isn't just for zipfiles? (I can easily imagine other
extensions that would benefit - tarfiles, metakit databases,
imports over the web, ...)
Paul.