[Python-Dev] More optimisation ideas

mike.romberg at comcast.net mike.romberg at comcast.net
Mon Feb 1 12:59:39 EST 2016


>>>>> " " == Barry Warsaw <barry at python.org> writes:

    >> On Feb 01, 2016, at 11:40 AM, R. David Murray wrote:
    
    >> I don't know about anyone else, but on my own development
    >> systems it is not that unusual for me to *edit* the stdlib
    >> files (to add debug prints) while debugging my own programs.
    >> Freeze would definitely interfere with that.  I could, of
    >> course, install a separate source build on my dev system, but I
    >> thought it worth mentioning as a factor.

   [snip]

     > But even with system scripts, I do need to step through them
     > occasionally.  If it were a matter of changing a shebang or
     > invoking the script with a different Python
     > (e.g. /usr/bin/python3s vs. /usr/bin/python3) to get the full
     > unpacked source, that would be fine.

  If the stdlib were to use implicit namespace packages
( https://www.python.org/dev/peps/pep-0420/ ) and the various
loaders/importers as well, then python could do what I've done with an
embedded python application for years.  Freeze the stdlib (or put it
in a zipfile or whatever is fast).  Then arrange PYTHONPATH to first
look on the filesystem and then look in the frozen/ziped storage.

  Normally the filesystem part is empty.   So, modules are loaded from
the frozen/zip area.  But if you wanna override one of the frozen
modules simply copy one or more .py files onto the file system.  I've
been doing this only with modules in the global scope.  But implicit
namespace packages seem to open the door for this with packages.

Mike


More information about the Python-Dev mailing list