global variables - how??
Gordon McMillan
gmcm at hypernet.com
Wed Apr 12 17:15:01 EDT 2000
Anders Eggers-Krag wrote:
> it is obvious not to use global variables except when the use of them is
> obvious,
> in my case I could otherwise send them along with every function, creating a
> huge
> overhead passing a million pointers around, using exactly the same amount of
> memory,
> or in fact more, than I would using globals.
Oh, it uses more memory all right (the code objects are larger,
and more stack gets used), but it's also significantly faster
(fewer name lookups).
> I did figure out how to do it myself after a lot of trying, but as you said
> it is ugly,
> but this really anoys me, and I *was* starting to like python...
There are a number of ways to do it (most of which will lose
the speed advantage). I don't find anything ugly about
everyone importing a common module, for example (or
passing around a single context object).
- Gordon
More information about the Python-list
mailing list