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

"Martin v. Löwis" martin at v.loewis.de
Mon Nov 6 19:00:22 CET 2006

Armin Rigo schrieb:
> My strong opinion on the matter is that importing a .pyc file if the .py
> file is not present is wrong in the first place.

There is, of course, an important use case (which you are addressing
with a different approach): people want to ship only byte code, not
source code, because they feel it protects their IP better, and also
for space reasons. So outright ignoring pyc files is not really an

> I know it's a discussion that comes up and dies out regularly.  My two
> cents is that it would be saner to have two separate concepts: cache
> files used internally by the interpreter for speed reasons only, and
> bytecode files that can be shipped and imported.

There once was a PEP to better control byte code file generation; it
died because it wasn't implemented. I don't think there is a strong
opposition to changing the status quo - it's just that you need a
well-designed specification before you start, a serious,
all-singing-all-dancing implementation, and a lot of test cases.
I believe it is these constraints which have prevented any progress


More information about the Python-Dev mailing list