With the following functions you can explicitely control what parts of your application get compiled.
object, rec=10) |
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:
c.__dict__
are bound (which means, for classes, all methods defined in the class but not in its parents).
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.
function-or-method, rec=10) |
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.
object) |
Note that Psyco currently cannot release the memory occupied by the compilation of a function.
proxy-object) |
unproxy(proxy(f))
is a new function object equal to f. Calling it does no longer invoke Psyco.
object) |
func or None) |
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.