2

As a simple example, I want to allow this kind of usage in a python script assuming mycustom_CType is an instance of my defined PyTypeObject in C:

print('foo' in mycustom_CType)

What slots and functions in PyTypeObject's struct does python need for this to work? I'm guessing possibly tp_iter and tp_iternext but I can't be sure since the python docs doesn't say that for those 2 struct fields.

1 Answer 1

2

The tp_as_sequence.sq_contains member of the type is invoked for containment checking.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.