有没有办法在不明确指定其类型的情况下接受 cython 函数中的参数?
Is there a way to accept an argument in a cython function without explicitly specifying its type?
我是 Cython 的新手。我正在尝试编写一个可以接受元组或列表作为参数的函数。
我知道将 void* 参数传递给 C++ 函数允许我们这样做(尽管我可能错了),但是对于 Cython 有类似的方法吗?
是否可以通过不必明确提及 tuple
或 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])
要么完全不使用任何类型,即,将其写成一个普通的 python 函数,要么 object
。在任何一种情况下,任何 python 对象 (PyObject*
) 都将被接受。
def shape_func(a, b):
return (a[0] > b[0])
我是 Cython 的新手。我正在尝试编写一个可以接受元组或列表作为参数的函数。
我知道将 void* 参数传递给 C++ 函数允许我们这样做(尽管我可能错了),但是对于 Cython 有类似的方法吗?
是否可以通过不必明确提及 tuple
或 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])
要么完全不使用任何类型,即,将其写成一个普通的 python 函数,要么 object
。在任何一种情况下,任何 python 对象 (PyObject*
) 都将被接受。
def shape_func(a, b):
return (a[0] > b[0])