Location of bytecode files (pyc)

Skip Montanaro skip at pobox.com
Wed Sep 3 14:49:50 EDT 2003


    Rim> As Bengt suggest, adding yet another env var to control the
    Rim> operation of an application polutes the name space for all
    Rim> applications, but each app only needs to look at the variables it
    Rim> is concerned with.  PYTHONBYTECODEBASE is a cleaner approach that
    Rim> has less overhead than a configuration file. Also, env variables
    Rim> are directly usable in makefiles, which makes them very attractive
    Rim> and easy to use for managing where compiler output goes.

You can also set sys.bytecodebase in your application code instead of
relying on PYTHONBYTECODEBASE.  That may not be helpful when doing a big pyc
compile, as when running compileall.py.  In that case, you can simply set
PYTHONBYTECODE base for that specific command.  Still, in your environment,
it sounds like you'd want to set it in the /etc/profile (or similar).  It
could still be set to a user-specific directory, just one that's on a
filesystem which is not backed up.

The intention was that the most common usage would be for a person to
execute something like

    PYTHONBYTECODEBASE=/tmp/$USER/python ; export PYTHONBYTECODEBASE

in their .profile (or equivalent for non-sh-style shells or platforms).
Clearly, other usage is possible however.

Skip





More information about the Python-list mailing list