'Python source code for built-in "in" operator

I am trying to find the implementation of the built-in in operator in the (C) Python source code. I have searched in the built-in functions source code, bltinmodule.c, but cannot find the implementation of this operator. Where can I find this implementation?

My goal is to improve the sub-string search in Python by extending different C implementations of this search, although I am not sure if Python already uses the idea I have.



Solution 1:[1]

In python 3.9, the bytecode COMPARE_OP was split into four distinct instructions, and CONTAINS_OP for 'in' and 'not in' tests.

That did not change the implementation of in operator, it's directly handled in Python/ceval.c, calling PySequence_Contains().

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ofey404