Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
作为一个简单的例子,我想在 python 脚本中允许这种用法,假设mycustom_CType是我PyTypeObject在 C 中定义的一个实例:
mycustom_CType
PyTypeObject
print('foo' in mycustom_CType)
PyTypeObjectpython 需要哪些结构中的插槽和函数才能使其工作?我猜可能tp_iter,tp_iternext但我不能确定,因为 python 文档没有对这两个结构字段说。
tp_iter
tp_iternext
调用该类型的tp_as_sequence.sq_contains成员进行包含检查。
tp_as_sequence.sq_contains