O'Reilly logo

Python Essential Reference, Second Edition by David M Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining New Types

New types of objects can also be defined in extension modules. However, this process is considerably more advanced than simply accessing a few C functions. Because of this complexity, you should consider implementing a new type only in the following situations:

  • The type is not easily constructed from existing Python types.

  • The type requires interaction with the operating system or another special feature not provided by the interpreter or the standard library.

  • The type hasn’t already been implemented elsewhere. For example, efficient matrix types have already been implemented, so it would make little sense to reinvent them. It’s always a good idea to check the Python libraries and newsgroups before implementing a new type. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required