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

Brett Cannon brett at python.org
Sat Nov 4 21:33:40 CET 2006

On 11/4/06, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> 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?

Yes, I think it should.  When I get around to rewriting zipimport for my
import rewrite it will do this by default.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20061104/40d3c521/attachment.html 

More information about the Python-Dev mailing list