set() runtime in python

python

Solution

`set` is implemented using a hash, so the lookup is, on average, close to O(1). The worst case is O(n), where n objects have colliding hashes.

Problem

Just wondering what the run time of lookup for set() is? O(1) or O(n)? if I have x = set() whats the runtime of if "a" in x: print a in set!

Original source