Changing signature of cpdef functions allowed?

10 views
Skip to first unread message

Jeroen Demeyer

unread,
Aug 9, 2017, 6:12:02 AM8/9/17
to cython-users
Cython seems to allow this:

cdef class Base:
cpdef meth(self):
pass

cdef class Derived(Base):
cpdef meth(self, arg=None):
pass

cdef class MoreDerived(Derived):
cpdef meth(self, arg=None, arg2=None):
pass


It is important that the additional argument "arg" is optional,
otherwise Cython gives an error "Signature not compatible with previous
declaration".

Now, I have two questions:

1) Does the above really work?

2) When adding a .pxd file, is it required to redeclare the cpdef method
in Derived and MoreDerived? When I don't, I get a warning "Compatible
but non-identical C method ... not redeclared". I want to know whether
this warning is justified.
Reply all
Reply to author
Forward
0 new messages