On Tue, Aug 30, 2011 at 10:19 AM, Vitja Makarov <vitja.maka...@gmail.com> wrote: > 2011/8/30 Stefan Behnel <stefan...@behnel.de>: >> Vitja Makarov, 30.08.2011 18:39: >>> >>> 2011/8/30 Stefan Behnel: >>>> >>>> Robert Bradshaw, 30.08.2011 18:18: >>>>> >>>>> On Tue, Aug 30, 2011 at 9:14 AM, Vitja Makarov wrote: >>>>>> >>>>>> What about final classes with cpdef methods? >>>>>> >>>>>> @cython.final >>>>>> class Foo: >>>>>> cpdef bar(self): >>>>>> pass >>>>>> >>>>>> Should that raise an error? >>>>> >>>>> That should be perfectly fine. >>>> >>>> Well, the 'final' decorator shouldn't work on normal Python classes. >>>> >>>> Regarding extension types, CPython has a way of declaring them 'final' >>>> with >>>> a type flag, which effectively prevents them from being subclassed in >>>> Python. So the above works as just fine for cdef classes. >>>> >>> >>> Ok. So final class could have cpdef methods but non-final extension >>> type couldn't, am I right? >> >> All extension types can have cpdef methods, be they final or not. For final >> classes, cpdef methods simply mean that they have a Python wrapper and will >> otherwise be called directly when called from Cython. >> >> Actually, for cpdef methods in final classes, we can even drop the override >> check in the DefNode wrapper. I don't think that currently happens. >> > > Currently I drop OverrideCheckNode for all final cpdef methods, see > https://github.com/cython/cython/pull/59/files#L2R1751 > > Final classes can have cpdef method that's ok. > Could non-final classes have final-cpdef methods?
No, as we can't prevent them from being overridden (violating the semantics of final). We should raise an error when trying to declare final cpdef methods in non-final classes. > Currently final class means that all its c[p]def methods are final too. Good point. - Robert _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel