[Python-Dev] Importing .pyc in -O mode and vice versa

"Martin v. Löwis" martin at v.loewis.de
Sat Nov 4 19:23:44 CET 2006

Fredrik Lundh schrieb:
>> However, I find the proposed behaviour reasonable: Python already
>> automatically imports the .pyc file if .py is not given and vice
>> versa. So why not look for .pyo if the .pyc file is not present?
> well, from a performance perspective, it would be nice if Python looked 
> for *fewer* things, not more things.

That's true.

> (wouldn't transparent import of PYO files mean that you end up with a 
> program where some assertions apply, and others don't?  could be con- 
> fusing...)

That's also true, however, it might still be better to do that instead
of raising an ImportError.

I'm not sure whether a scenario were you have only .pyo files for
some modules and only .pyc files for others is really likely, though,
and the performance hit of another system call doesn't sound attractive.

So I guess that zipimport should stop importing .pyo files if
OptimizeFlag is false, then?


More information about the Python-Dev mailing list