[Cython] non-virtual methods

Stefan Behnel stefan_ml at behnel.de
Tue Aug 30 10:07:37 CEST 2011

Robert Bradshaw, 30.08.2011 07:32:
> On Sun, Aug 28, 2011 at 4:00 AM, Vitja Makarov wrote:
>>> I've created pull request:
>>> https://github.com/cython/cython/pull/59
>> I've add support for inline methods, now you can declare inline method
>> in pxd file:
>> cdef class Foo:
>>    cdef inline foo(self):
>>        return 1
> Cool.

+1 :)

> I'm not seeing how you're disallowing
> overriding final cpdef methods from Python.

We could check for an override in the DefNode wrapper code at runtime. 
However, if it has been overridden, we won't even get there when called 
from Python, so we will never know if it has been overridden (well, we 
could add a check to tp_new(), but that would only catch overrides at class 
instantiation time, not attribute assignments).

It's certainly easier and safer to reject this case at compile time, 
providing a very specific error message.


More information about the cython-devel mailing list