[Python-Dev] module extension search order - can it be changed?

Guido van Rossum guido@python.org
Tue, 25 Feb 2003 10:26:51 -0500


>     Skip> [check .py before .so]
> 
>     Guido> I don't know if it would break something, but it was certainly
>     Guido> intended as a feature: you could have an extension and a .py
>     Guido> module in the same directory, the .py module would be used as a
>     Guido> fallback if the .so cannot be built.
> 
> This doesn't quite make sense to me.  Instead of ".so cannot be built" did
> you mean ".so cannot be imported"?

No, I meant what I said.  Once the file is found, it will be tried
and if that fails, the other files won't be tried.  The idea was that
if the .so cannot be built, it won't be installed -- but the .py will
be there at all times.

> In any case, the current solution to my underlying problem (so many failing
> stat() calls during module import) appears to be to create
> $prefix/python23.zip and populate it with the contents of the standard
> library using zipfile.PyZipFile.

Right, that's what zipimport is for.

--Guido van Rossum (home page: http://www.python.org/~guido/)