[Pyrex] class attributes for extension types

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Sep 12 12:16:33 CEST 2005


Simon Burton wrote:
> I've just been working out how to do classmethod's for c extension types
 > (use METH_CLASS), and I assume it's also possible to set class
> attributes  (by setting a tp_setattro in the type object struct).

I just had a peek at the docs, and it looks like METH_CLASS will
work (and METH_STATIC too).

But I don't think you can get class attributes using tp_setattro,
because that's only invoked for setting attributes on instances of the 
class, not the class itself. You'd need to override the tp_setattro
of the metaclass, and trying to envisage an extension type with
a custom metaclass is making my head spin rather too much just at
the moment.

> So, I guess this is a feature request for pyrex to support this,

I'll put METH_CLASS and METH_STATIC on the list, and maybe give
metaclasses a bit more thought sometime.

Greg



More information about the Pyrex mailing list