有没有办法在没有明确指定其类型的情况下接受cython函数中的参数?

时间:2018-02-22 21:31:46

标签: python types cython void-pointers

我是Cython的新手。我正在尝试编写一个可以接受元组或列表作为参数的函数。

我知道将void *参数传递给C ++函数允许我们这样做(尽管我可能错了),但是有没有类似的方法为Cython执行此操作?

有没有办法将以下内容合并为一个,而不必明确提及tuplelist? -

def shape_func(tuple a, tuple b) :
    return (a[0] > b[0])

def shape_func(list a, list b) :
    return (a[0] > b[0])

1 个答案:

答案 0 :(得分:3)

根本不使用任何类型,即将其写为普通的python函数,或object。在任何一种情况下,都会接受任何python对象(PyObject*)。

def shape_func(a, b):
    return (a[0] > b[0])
相关问题