Using alternative PyObject* in dynamically created classes
Ronald Oussoren
ronaldoussoren at mac.com
Tue Nov 23 16:07:12 EST 2004
More information about the Python-list mailing list
Tue Nov 23 16:07:12 EST 2004
- Previous message (by thread): Using alternative PyObject* in dynamically created classes
- Next message (by thread): Using alternative PyObject* in dynamically created classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 23-nov-04, at 14:07, Jacek Generowicz wrote: > Jacek Generowicz <jacek.generowicz at cern.ch> writes: > >> I would like some of my _dynamically_ created new-style classes to >> have instances which are not represented by the standard PyObject, but >> one which has an extra void* slot which I want to use for my nefarious >> purposes, in extension functions. The pointer need not be initialized >> (for now) I just want it to be there in case I want to stuff something >> in there later on in the run. >> >> What is the laziest way of achieving this? >> >> As far as I can tell, PyTypeObject (and its allocators, deallocators, >> methods in general) only refer to the type of the instance struct via >> tp_basicsize (where only the struct's size is held). >> >> So my first attempt merely resets tp_basicsize to the size of my >> alternative instance struct, as soon as the class is created. This >> goes horribly wrong when instances of the class are deallocated, but I >> can't see why. >> >> Where else must I provide information about the instance struct type ? >> >> >> [I will be away for a few days, from a few hours from now; please >> don't take a long response time as a sign of rudeness.] > > > Hmm ... no takers ? > > :-( Appearently not :-). Do you want to create those classes in Python, or from your extension module? If you create the class in C its easy to add a hidden slot. You can even add a field to the type object that contains the location of that hidden slot. Ronald
- Previous message (by thread): Using alternative PyObject* in dynamically created classes
- Next message (by thread): Using alternative PyObject* in dynamically created classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list