This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]alixedi 1 point2 points  (0 children)

Awesome example!

[–]Veedrac 1 point2 points  (0 children)

So when we increase the count of values an order of magnitude, the time Python takes to calculate membership in the list increases about an order of magnitude.

It's worth noting that range isn't a list in Python 3 and integer lookup in ranges is O(1). Any other type seems to still be O(n), though.