No no. The is operator is simply not needed, which often justifies the need to support a C-optimized method and add confusion to the python API.
The in test for lists and tuples performs a full search, similar to any , albeit in C, btw. However, the tests use the efficient storage algorithm underlying the container, and the search requires constant time in the expected case. For both sets and mappings, the keys must have a stable hash, which in most cases means that is not required, really.
So, the correct spelling:
# For sequences any(y is item for item in container)
Martijn pieters
source share