pickle and module package

M.-A. Lemburg mal at lemburg.com
Tue May 18 09:22:31 EDT 1999


Stefan Franke wrote:
> 
> >One thing I have stumbled into when starting off into the
> >package business was that:
> >
> >from MyPackage import ThisModule
> >import ThisModule
> >
> >yield *two* imports of the same module if done from a
> >module in the MyPackage directory -- the module is
> >initialized twice which causes a lot of trouble sometimes.
> 
> Uhh, I just checked this. This is definitely not something I would have
> expected. Is there any rationale behind?

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.

-- 
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