2.2 Old-style classes vs. Built-in types

Althought Psyco can plug itself over various versions of the interpreter, there are some features that depend on specific extensions. Extra features only available from Python 2.2.2 (not in 2.2) are depending on new hooks that the core interpreter offer. While minor, these hooks are crucial for some features and they are the reason I recommend to upgrade your Python installation to 2.2.2. On the other hand, differences between Python 2.1 and the 2.2 series are due to the general-purpose enhancements done by the Python team between these releases.

A major introduction of Python 2.2 are the so-called new-style classes, which have a (positive) performance impact on Psyco. So with Python 2.2 you should, as much as possible, let your classes be built-in types and not old-style classes. This means that your classes should inherit from object (directly or not; if its parent inherit from object it is fine). This lets Psyco produce faster code. Even better, if you add the line

from psyco.classes import *

at the top of the module(s) that define the classes, then not only will all your classes automatically inherit from object, but all the methods defined in your classes will automatically be compiled as if you had called psyco.bind() on them.

Warning: In Python, instances of classes that inherit from a built-in type are subject to some semantic differences that you should know about. These are described in http://www.python.org/2.2.2/descrintro.html. An immediate difference is that if x contains an instance of such a new-style class, then type(x) will be x.__class__ instead of types.InstanceType.

In Python 2.1 there are no user-defined built-in types. The statement "from psyco.classes import *" has no effect but does not hurt.