pythonic way to optimize access to imported value?

Aahz aahz at pythoncraft.com
Fri Nov 29 08:05:56 EST 2002


In article <arb8a0$rfm$0 at 216.39.172.122>, Bengt Richter <bokr at oz.net> wrote:
>
>E.g., if you had a program that needs a lot of memory and does
>processing in distinct phases. Obviously you can split the job into
>separate programs that use temp files. But what if you want use memory
>to communicate between phases? E.g., load a module that retrieves
>data from the net, another that parses it and builds convenient data
>structures, another that requires an interactive GUI to classify
>visually presented data, another to create a backup of clean data and
>editing log, another to generate pdf reports, etc. etc.  The succeeding
>phases are going to suffer from memory squeeze if you can't unload
>modules that you no longer need.
>
>If you load a module that needs another, of course reference counting
>should work as it does, but when you unload a module explicitly, IMO it
>ought to be a bit like clearing a dict. A lot of references will get
>decremented, and some will go to zero. Why not a module's reference
>count, to let it disappear when no longer needed (or have it held in an
>LRU cache to be bumped as necessary)?

With the exception of C libraries, I'm not aware of any *modules* that
are such a memory drain, although they may store data that is a memory
drain.  And C libraries are going to be much harder to unload, to the
point that I'd bet Guido would quickly veto any such proposal.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"If you don't know what your program is supposed to do, you'd better not
start writing it."  --Dijkstra



More information about the Python-list mailing list