Is it possible to define a class c __getitem__that takes an argument tupleusing the Python C-API? Element sq_itemMember tp_as_sequenceelement PyTypeObject has to be ssizeargfunc, so I do not see how to do it. (But I guess NumPy ndarraydoes this.)
__getitem__
tuple
sq_item
tp_as_sequence
PyTypeObject
ssizeargfunc
ndarray
Yes, use tp_as_mappinginstead.
tp_as_mapping
It mp_subscripttakes it PyObject *, so you can use anything as an index / key.
mp_subscript
PyObject *
, , PyObject_GetItem(), ( ) Python o[key]. , tp_as_mapping, , int, tp_as_sequence.
PyObject_GetItem()
o[key]
int