A smarter(?) package importer.
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Wed Nov 7 22:30:05 EST 2001
>>>>> "GMcM" == Gordon McMillan <gmcm at hypernet.com> writes:
>> 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].
GMcM> It really does do all those opens. If Windows had strace, it
GMcM> would be easy to verify.
Yes, you are right. find_module does use open underneath. Thanks for
the information.
write(1, "Importing foo (pkg/sub1/foo.pyc)"..., 37Importing foo (pkg/sub1/foo.pyc)...
) = 37
stat("pkg/sub1/a", 0xbfffe08c) = -1 ENOENT (No such file or directory)
open("pkg/sub1/a.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("pkg/sub1/amodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("pkg/sub1/a.py", O_RDONLY) = -1 ENOENT (No such file or directory)
[snip]
GMcM> [back to recursive-relative imports]
>> So, I'll ask again, how about making this behaviour standard?
>> :)
GMcM> I think not. I'd rather see import get less magical than
GMcM> more magical.
GMcM> If "import" meant "absolute import", and "rimport" meant
GMcM> "relative import" (and maybe "rrimport" meant "recursive
GMcM> relative import") then all name- masking problems would
GMcM> disappear.
That sounds ok but this adds 2 more keywords to Python. Anyway, so
long as something that handles rr/rimport is added I'm happy. Should
I make a request on python-dev about this?
prabhu
More information about the Python-list
mailing list