[Cython] non-virtual methods

Stefan Behnel stefan_ml at behnel.de
Tue Aug 30 18:41:49 CEST 2011


Vitja Makarov, 30.08.2011 18:36:
> 2011/8/30 Robert Bradshaw:
>> 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.

Robert meant to say that the above code is fine and should *not* raise an 
error.


> I'm not sure here. This would make users write code like this:
>
> @final
> cdef class Foo:
>      cdef _is_foo(self):
>          return self._foo
>
>      def is_foo(self):
>          return self._is_foo()
>
> cpdef is more convinient here. Also note that final class couldn't
> subclass types with cpdef methods.

Right.

Stefan


More information about the cython-devel mailing list