Creating a new type with an extension module
tim_one at email.msn.com
Mon Jun 21 17:46:55 CEST 1999
> 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.
> http://www.python.org/doc/current/api/newTypes.html 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