A.2 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  Notes 
globals  
locals (1)
vars (1) when called with no argument
dir (1) when called with no argument
eval (2) when called with a single argument
execfile (2) when called with a single argument
input (2)
sys._getframe (3)

Notes:

(1)
A function run by Psyco has no locals dictionary. Trying to access it returns an empty dictionary and issues a psyco.warning.
(2)
Functions performing dynamic evaluations cannot see the current locals. You should explicitely supply a globals and/or locals dictionary to these functions. They issue a psyco.warning if you don't. Use raw_input and the three-arguments form of eval instead of input.

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 A.1.

Additionally, the exec statement is not supported yet, as seen in section A.3.