3.1 Selecting the functions to compile

With the following functions you can explicitely control what parts of your application get compiled.

bind( object, rec=10)
Tells Psyco that the given object should be compiled for faster execution.

If object is a Python function, bind modifies the function object in-place (specifically, its func_code attribute is changed). All future calls to the function will go through Psyco. Remember that in Python no behavior can depend on which reference to the function you use to make the call; in other words, after

g = f
bind(f)

calls to both f and g will go through Psyco.

The object argument can also be:

Note that compilation never actually starts before a function is first called.

All functions called by a compiled function are also compiled, as well as the functions called by these, and so on, up to some limit (by default 10) that you can specify as the optional second argument.

proxy( function-or-method, rec=10)
Makes a Psyco-enabled copy of object.

This function returns a new object, which is a copy of the function-or-method with the same behavior but going through Psyco. The function or method must be implemented in Python. The argument itself is not affected; if you call it, it will still be run by the regular interpreter.

Thus, "bind(f)" is similar to "f=proxy(f)", except that any reference to f that might previously have been taken (for example by a "from spam import *" statement) are unaffected in the second case.

unbind( object)
Cancels the action of bind.

Note that Psyco currently cannot release the memory occupied by the compilation of a function.

unproxy( proxy-object)
Reverse of proxy.

unproxy(proxy(f)) is a new function object equal to f. Calling it does no longer invoke Psyco.

The same function will never be compiled over and over again, so that you can freely mix calls to bind, proxy, unbind and unproxy and to the profile-based routines described in the next section.