Reputation: 426
I am a newbie to Cython. I am trying to write a function that can accept either a tuple or list as an argument.
I understand that passing a void* argument to a C++ function allows us to do this (though I might be wrong), but is there a similar way to do this for Cython?
Is there a way to merge the following into one by not having to explicitly mention tuple
or list
? -
def shape_func(tuple a, tuple b) :
return (a[0] > b[0])
def shape_func(list a, list b) :
return (a[0] > b[0])
Upvotes: 0
Views: 267
Reputation: 52246
Either use no type at all, i.e., write it as if it were a normal python function, or object
. In either case, any python object (PyObject*
) will be accepted.
def shape_func(a, b):
return (a[0] > b[0])
Upvotes: 3