[Python-Dev] startup time repeated? why not daemon

Larry Hastings larry at hastings.org
Fri Jul 21 22:59:08 EDT 2017


On 07/21/2017 03:28 PM, Barry Warsaw wrote:
> The TPI (Terrible Python Idea) I had at Pycon was some kind of (local)
> memcached of imported Python modules, which would theoretically allow avoiding
> loading the modules from the file system on start up.
>
> There would be all kinds of problems with this (i.e. putting the "terrible" in
> TPI), such as having to deal with module import side-effects, but perhaps
> those could be handled by enough APIs and engineering.

This would be taking a page out of PHP's book.

PHP--or at least, PHP ten years ago--doesn't have the equivalent of .pyc 
files.  If you have mod_php running inside Apache with no other 
extensions, it literally tokenizes each .php script every time it's invoked.

To solve this performance problem, someone wrote the "Alternative PHP 
Cache" (or "APC"), which runs /in Apache/.  (Yep, it's not usable 
outside Apache!)  APC stores the tokenized versions of PHP scripts in 
something approximating their actual in-memory representation.  To use 
something stored in the cache, you'd iterate over all the 
variables/functions, copy each one into your local interpreter instance, 
and perform fixups on all the pointers to convert them from relative to 
absolute addresses.

    http://php.net/manual/en/book.apc.php


I note that the introduction to APC says:

    Warning
    This extension is considered unmaintained and dead. However, the
    source code for this extension is still available within PECL.

So perhaps the PHP folks have moved on from this technique.


//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170721/8eae8300/attachment.html>


More information about the Python-Dev mailing list