Fred L. Drake, Jr.
fdrake at acm.org
Mon Jun 7 14:21:54 EDT 2004
On Monday 07 June 2004 01:21 pm, Jiwon Seo wrote:
> It looks like it's because even if the package failed to be loaded, it
> should be added to its parent module dict, IMHO.
> The comment in the import.c::add_submodule describes the behavior. I
> don't know how it could be useful, but I think it's the way import
This is to support caching; if some module in the "foo" package imports the
"bar" module, and there isn't a "foo.bar" module, sys.modules grows a
"foo.bar": None entry so that further attempts to import sys within the "foo"
package don't have to do as much work to know that there isn't one, and can
fall back to a top-level "bar" module (which can still fail if there isn't
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Zope Corporation
More information about the Python-Dev