Robert Bradshaw wrote:
> On Nov 11, 2008, at 1:22 AM, Stefan Behnel wrote:
>>     @cython.cclass(attr1=cython.int, ...)        # Py3 only

This actually works in Py2.6 also, where a

    @cython.cclass
    class A: pass

would still be an old-style class. So, using a class decorator here will
not guard us from decorated classes becoming old-style classes in CPython.

The decorator actually gets the readily created class as argument, which
is an old-style class already. Fixing that into a new-style class will not
work. So the only chance we have is really a metaclass, or just an
enforced requirement that any decorated class must inherit from object,
i.e. it must be a type.

Not only in this case would it be nice to allow extension classes to
inherit from object in Cython without any additional setup. Currently, you
have to ctypedef the object type yourself to do that. We could override an
"object" base class and just emit a plain extension type instead.

BTW, Py3 (not Py2.x) would also allow this syntax when using a metaclass:

    class A(metaclass=cython.cclass): pass

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to