54 lines
2.0 KiB
Plaintext
54 lines
2.0 KiB
Plaintext
From: mal at lemburg.com (M.-A. Lemburg)
|
|
Date: Tue, 18 May 1999 19:07:44 GMT
|
|
Subject: pickle and module package
|
|
References: <s74018da.014@mail.conservation.state.mo.us>
|
|
<37408338.41341C94@lemburg.com>
|
|
<37415299.1269044@news.omnilink.de>
|
|
<37416997.3810214C@lemburg.com> <14145.40544.797779.223676@weyr.cnri.reston.va.us>
|
|
Message-ID: <3741BA80.3FA2AD1D@lemburg.com>
|
|
Content-Length: 1588
|
|
X-UID: 1930
|
|
|
|
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/
|
|
|
|
|
|
|
|
|
|
|