pickle and module package

Fred L. Drake fdrake at cnri.reston.va.us
Tue May 18 13:07:44 EDT 1999


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!


  -Fred

--
Fred L. Drake, Jr.	     <fdrake at acm.org>
Corporation for National Research Initiatives




More information about the Python-list mailing list