pickle and module package

M.-A. Lemburg mal at lemburg.com
Tue May 18 15:07:44 EDT 1999


Fred L. Drake wrote:
> 
> M.-A. Lemburg writes:
>  > I'd say, there's no way for the import logic to tell whether
>  > you are about to import the same module a second time... unless
>  > maybe, if it scans the sys.modules dict for filenames of the modules
>  > and then checks for identical files. But that would reduce import
>  > performance dramatically and not be worth it.
> 
>   A dictionary could be used that maps filenames to modules; this can
> simply be checked and updated during the slow path through import.
> This shouldn't be much slower than it already is.  ;-)
>   The filesnames would have to be absolute for it to work; there's
> currently nothing that does this for pathnames in the core
> interpreter.  I'd be quite happy if __file__ could be relied on to be
> absolute as well!

Hmm, so maybe there's a chance after all... a dictionary lookup
would certainly not effect the import performance in any
noticable way.

That would also provide a chance to get that fastpath hook into
the mechanism to eliminate at least a few of the stat() calls
done at startup.

Just wish I had some time to look into this a bit further...
if anyone wants to try, here is the fastpath stuff I've
written some time ago:

	http://starship.skyport.net/~lemburg/fastpath.zip

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                   227 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/





More information about the Python-list mailing list