3.4 The psyco.classes module

The psyco.classes module defines a practical metaclass that you can use in your applications.

A metaclass is the type of a class. Just like a class controls how its instances behave, a metaclass controls how its classes behave. The purpose of the present metaclass is to make your classes more Psyco-friendly.

class psymetaclass
The new metaclass. This is a subclass of psyco.compacttype. Any user-defined class using this metaclass will be a new-style class and will automatically bind all the methods defined in the class body for compilation with Psyco. It will also automatically inherit from psyco.compact (see section 3.5).

class __metaclass__
A synonym for psymetaclass.

class psyobj
An empty class whose metaclass is psymetaclass, suitable for subclassing in the same way that the built-in object is the generic empty new-style class which you can subclass.

See http://www.python.org/2.2.2/descrintro.html for more information about old-style vs. new-style classes. Be aware of the changes in semantics, as recalled in section 2.3 (Psyco tutorial).

By using psyco.classes.__metaclass__ as the metaclass of your commonly-used classes, Psyco will call psyco.bind for you on all methods defined in the class (this does not include inherited parent methods or methods added after the class is first created). Additionally, these classes are ``compact'' (section 3.5), i.e. Psyco can produce quite fast code to handle instances of these classes and they use less memory each.