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_ContainsinObjects/abstract.c. I found it by looking through the implementation ofoperator.containsinModules/operator.c, which wraps all the native operators in Python functions.