__pycache__, one more good reason to stck with Python 2?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Jan 19 16:43:12 EST 2011


On Wed, 19 Jan 2011 11:30:36 -0800, Carl Banks wrote:

> On Jan 19, 6:42 am, Steven D'Aprano <steve
> +comp.lang.pyt... at pearwood.info> wrote:
>> But having said that, the __pycache__ idea isn't too bad. If you have
>> this directory structure:
>>
>> ./module.py
>> ./module.pyc
>>
>> and import module, the top-level .pyc file will continue to be used.
> 
> Nope.  PEP 3147 says it now always uses __pycache__.


Looks like the PEP is outdated then.

[steve at sylar ~]$ rm __pycache__/*
[steve at sylar ~]$ echo "print('spam spam spam')" > spam.py
[steve at sylar ~]$ python3.2 -m compileall spam.py
Compiling spam.py ...
[steve at sylar ~]$ mv __pycache__/spam.cpython-32.pyc ./spam.pyc
[steve at sylar ~]$ python3.2 -m spam
spam spam spam
[steve at sylar ~]$ ls __pycache__/
[steve at sylar ~]$



-- 
Steven



More information about the Python-list mailing list