[Python-Dev] __file__

Barry Warsaw barry at python.org
Thu Feb 25 21:47:47 CET 2010

On Feb 03, 2010, at 01:07 PM, Antoine Pitrou wrote:

>Well, I don't think we need another transition... Just keep __file__ for the
>source file, and add a __cache__ or __compiled__ attribute for the compiled 

>Since there might be several compiled files for a single source file (for
>example, a .pyc along with a JITted native .so), __cache__ should probably be
>a tuple rather than a string.

I'm going to call the attribute __cached__ and leave its contents
implementation defined.  For CPython it will be the path to the pyc file if it
exists (or was written), or the path to where the pyc file /would/ exist if
the source lives on a read-only file system or -B/$PYTHONDONTWRITEBYTECODE is

For alternative implementations of Python that compose modules from multiple
sources, __cached__ can be a tuple.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100225/6f6721c4/attachment.pgp>

More information about the Python-Dev mailing list