Automatic, portable optimization of global access
Raymond Hettinger
python at rcn.com
Thu Apr 15 11:21:05 EDT 2004
FWIW, I've posted a brief, but powerful recipe for a bytecode
optimization that saves known globals as constants:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/277940
It's not psyco, but it does run everywhere and is easy to use.
A key benefit is being able to localize variable access without adding
clutter to your code like: _random=random; _len=len.
One caveat is to run it in the builtin_only mode whenever some of the
module globals are going to be updated at runtime.
Raymond Hettinger
More information about the Python-list
mailing list