2.3 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.

A major introduction of Python 2.2 are the so-called new-style classes, which have a (positive) performance impact on Psyco. So you should, as much as possible, let your classes be built-in types and not old-style classes (which is done by inheriting from another new-style class, or from object for root classes).

In addition, Psyco 1.4 provides a compact alternative to Python's new-style instances: the psyco.compact root class. Currently, you have to use or inherit from psyco.compact explicitely. This lets Psyco produce faster code and reduces the memory used by your instances. 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 psyco.compact, 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.

For more information see sections 3.4 and 3.5.