I became curious about the implementation of the "in" (__contains__
?) operator in python due to this SO question. I downloaded the source code and tried to grep, browse, etc. to find some base definition of it, but I haven't been successful. Could someone show me a way to find it?
Of course a general approach to finding that kind of thing would be best so anyone like me can learn to fish for next time.
I'm using 2.7 but if the process is totally different for 3.x, that would be nice to have both techniques.
I think the implementation starts in PySequence_Contains
in Objects/abstract.c
. I found it by looking through the implementation of operator.contains
in Modules/operator.c
, which wraps all the native operators in Python functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With