Python "in" operator speed

in-operator, python, size, time

Solution

A summary for in:

list - Average: O(n)
set/dict - Average: O(1), Worst: O(n)

See this for more details.

Problem

Is the `in` operator's speed in python proportional to the length of the iterable? So, ``` len(x) #10 if(a in x): #lets say this takes time A pass len(y) #10000 if(a in y): #lets say this takes time B pass ``` Is A > B?

Original source