On 1 February 2010 00:34, Nick Coghlan <ncogh...@gmail.com> wrote: > > __file__ would always point to the source files > __file_cached__ would always point to the relevant compiled file (either > pre-existing or newly created) > > > I like this solution combined with having a single cache directory and a few other things I've added below.
The pyc/pyo files are just an optimisation detail, and are essentially temporary. Given that, if they were to live in a single directory, to me it seems obvious that the default location for that should be in the system temporary directory. I an immediately think of the following advantages: 1. No one really complains too much about putting things in /tmp unless it starts taking up too much space. In which case they delete it and if it gets reused, it gets recreated. 2. /tmp is often on non-volatile memory. If it is (e.g. my Windows system temp dir is on a RAMdisk) then it seems wise to respect the obvious desire to throw away temporary files on shutdown. 3. It removes the need for people in general to even think about the existence of pyc/pyo files. They could then be relegated to even more of an implementation detail (probably while explaining the command-line options). 4. No need (in fact undesireable) to make it a hidden directory. If you wanted to package up the pyc/pyo files, I've got an idea that combines well with executing a zip file containing __main__.py (see other thread) 1. Delete /tmp/__pycache__. 2. Compiling all your source files with the versions you want to support (so long as they supported this mechanism). 3. Add a __main__.py which sets the cache directory to the directory (zip file) that __main__.py is in. __main__.py (as the initial script) doesn't use the cache. 4. Zip up the contents of /tmp/__pycache__. Note that for this to work properly it would either require an __init__.py to be automatically created in the __pycache__ module subdirectory, or have the subdirectory be named as a .pyr to indicate it's a cached module (and thus should be importable). /tmp/__pycache__ __main__.py foo.pyr/ foo.py32.pyc foo.py33.pyc Tim Delaney
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com