global vars across modules

Roy Smith roy at panix.com
Sun Apr 22 16:53:18 EDT 2012


In article 
<11146533.5.1335125285850.JavaMail.geo-discussion-forums at pboo1>,
 mamboknave at gmail.com wrote:

> On Sunday, April 22, 2012 12:48:23 PM UTC-7, Roy Smith wrote:
> ....
> > Answer 1: You can't.
> > 
> > Answer 2: You might want to look at thread local storage 
> > (http://docs.python.org/library/threading.html#threading.local).
> > 
> > Answer 3: Are you sure you really want to do this?
> 
> Thanks! Here is what I need to do, perhaps you can give me some hints.
> 
> A generic module, used across different independent programs, puts its 
> computing results in a var fairly big, ~50KB.

Why do they do that?  Why don't they just return the result?

> How can I do? I cannot think of making that var local and 'returning' ~50KB 
> all the times the module is called.

Why not?  If you return a 50 kb string or some other data structure, 
you're not actually copying 50 kb of data, you're just returning a 
handle to the data object.



More information about the Python-list mailing list