[Python-Dev] Re: creating struct-seq types from Python
Martin v. Loewis
martin@v.loewis.de
17 Oct 2002 20:28:54 +0200
"Fred L. Drake, Jr." <fdrake@acm.org> writes:
> Have you looked at what it would take to create new "structure
> sequence" types from Python code?
Not really, but I think all you need to do is to expose
PyStructSequence_InitType. I would recommend an interface like
struct_seq(name, doc, n_in_sequence, (fields))
where fields is a list of (name,doc) tuples. You will need to
temporarily allocate a PyStructSequence_Field array of len(fields)+1
elements, and put the PyStructSequence_Desc on the stack. You will
also need to dynamically allocate a PyTypeObject which you return.
I would put this into the new module.
Regards,
Martin