【发布时间】:2021-06-10 14:25:08
【问题描述】:
我在 Cython 2.0 下运行这段代码时遇到了一些问题:
cdef class Foo(object):
cpdef twerk(self): #using def instead does not help
print "Bustin' some awkward moves."
cdef class ShyFoo(Foo):
cpdef twerk(self):
print "Do I really have to?"
super(self, ShyFoo).twerk()
print "I hate you so much."
ShyFoo().twerk()
RuntimeError: 调用 Python 对象时超出最大递归深度
但是,删除 cdefs 并将 cpdefs 替换为 defs 可以让我使用 Python。
回溯是这样的:
File "mytest.pyx", line 61, in mytest.Foo.twerk
cpdef twerk(self):
File "mytest.pyx", line 67, in mytest.ShyFoo.twerk
super(ShyFoo, self).twerk()
File "mytest.pyx", line 61, in mytest.Foo.twerk
cpdef twerk(self):
File "mytest.pyx", line 67, in mytest.ShyFoo.twerk
super(ShyFoo, self).twerk()
....................................................
我做错了什么?我从 4 年前找到了this relevant ticket,但我猜它因为用户错误而没有引起注意。
【问题讨论】:
标签: cython