Next: Unsupported Python constructs
Up: Caveats
Previous: Known bugs
Contents
Patched functions
When Psyco starts, it replaces a few functions from the __builtin__ and sys modules with a version of its own. This trick fails if you made a copy of one of these functions elsewhere before Psyco has a chance to replace it, because the old copy will not behave properly in the presence of Psyco.
(built-in function)
globals
locals
vars
dir
eval
execfile
input
sys._getframe
_getframe (sys)
22#22
Notes:
- (1)
- A function run by Psyco has no native locals dictionary. Psyco 1.3 and above can emulate it properly if a certain optimization (early dead variable deletion) is disabled. Psyco should turn off this optimization automatically for functions where it detects a call to one of the above built-in functions, but this detection is a guess over the function's bytecode. It means that certain indirect calls can be missed. If this occurs at run-time, a psyco.warning is issued and the emulated locals dictionary is empty.
- (2)
- Note that it is common to find Python programs that use dynamic code evaluation for an effect that can be obtained by calling an ad-hoc built-in function instead. For example, eval('self.'+attr) is better written as getattr(self, attr) and exec 'import '+module is better written as __import__(module, globals(), locals(), []).
- (3)
- Frames corresponding to Psyco-evaluated functions are incomplete, as described in section
.
Additionally, the exec statement is not supported yet, as seen in section
.
Next: Unsupported Python constructs
Up: Caveats
Previous: Known bugs
Contents
2011-11-26