I am trying to define some built-in arithmetic operations for a cdef class in a Cython file.
At first I tried making the __pow__ function like so:
def __pow__(self, other, modulo=None):
pass
But received the following error message when compiling:
This argument cannot have a default value
(The argument the error message refers to is modulo)
Removing the default value for modulo allows the file to compile properly, but forces the user to provide the third argument, which is not only strange and annoying, but it also prevents the use of the ** operator (pow would have to be used instead).
How can I implement __pow__ in Cython such that the third argument is optional?