Creating a new type with an extension module

Tim Peters tim_one at
Mon Jun 21 11:46:55 EDT 1999

[Sion Arrowsmith]
> Is there any documentation anywhere on how to go about writing an
> extension which implements a new type? The extending/embedding
> tutorial give me, very quickly and painlessly, a module with
> functions, but I could really do with them being object methods.
> is unhelpful
> in the extreme

Everything important is there -- it's just missing all the words <wink>.

> -- do I have to resort to reading source?

Better, copy the source for some existing type and edit it.  The
implementations of the builtin types are in the source distribution's
Objects directory; e.g., floatobject.c implements Python floats, and
listobject.c implements (no, I'm not telling <wink>).  Browse those to get a
feel for it, then look at xxobject.c.  That's a skeleton object
implementation you can start from.

    y'rs  - tim

More information about the Python-list mailing list