A smarter(?) package importer.

Gordon McMillan gmcm at hypernet.com
Wed Nov 7 15:25:21 EST 2001


Prabhu Ramachandran wrote:

>>>>>> "GMcM" == Gordon McMillan <gmcm at hypernet.com> writes:

[snip]

>     GMcM> If you *don't* cache failure, you get 3 (4 on Windows)
>     GMcM> attempted opens per directory that you could have avoided.
> 
> Well, I'm not sure it does 3/4 opens but yes it does do 3/4
> imp.find_modules which will be more expensive than a
> sys.modules[mod_name].

It really does do all those opens. If Windows had strace, it would be easy 
to verify.
 
[back to recursive-relative imports]

> So, I'll ask again, how about making this behaviour standard? :)

I think not. I'd rather see import get less magical than more magical.

If "import" meant "absolute import", and "rimport" meant "relative import" 
(and maybe "rrimport" meant "recursive relative import") then all name-
masking problems would disappear.

- Gordon



More information about the Python-list mailing list