[Python-Dev] Heap allocated type objects from C

Eric Huss ehuss at ironport.com
Fri Jun 25 21:38:25 EDT 2004

I've been messing around with dynamically generating type objects from C.
In particular, I made a module to generate structseq type objects.
See sourceforge bug 624827 and patch 980098.

I ran into a fair amount of difficulty in doing this.  There doesn't
appear to be a direct C API for doing this.  One possible method is
calling PyType_Type.tp_new() and then updating the returned type object as
needed, but that seemed a little dirty.

First, could someone tell me if I took the correct route for creating a
type object on the heap (based on my patch).

Second, shouldn't there be a more direct API for doing this?  Perhaps a
more generalized interface to type_new(), or maybe something completely


More information about the Python-Dev mailing list