[Python-Dev] __file__ and bytecode-only

Nick Coghlan ncoghlan at gmail.com
Thu Mar 4 14:34:10 CET 2010


Barry Warsaw wrote:
> On Mar 03, 2010, at 07:37 PM, Jim Jewett wrote:
> 
>> I understand the need to ship without source -- but why does that
>> require supporting .pyc (or .pyo) -only?
>>
>> Couldn't vendors just replace the real .py files with empty files?
> 
> Yes, I think that's a possibility.  What would people think about that?

I actually thought of this, but didn't post it because it defeats the
point of byte-code only distribution.

- putting text in the .py file will break the application
- touching the .py file in any way will break the application

If someone wants to break the bytecode only support it should be its own
PEP and not coupled with PEP 3147.

The remaining open question to my mind is whether or not there should be
a -X option to control the bytecode generation. E.g.:

-Xcache_bytecode=no (don't write bytecode files at all)
-Xcache_bytecode=file (write a classic "foo.pyc" file)
-Xcache_bytecode=dir (write to the "__pycache__" directory)

With cache_bytecode=dir being the default for future releases.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list