Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?

It is my understanding that the range() function, which is actually an object type in Python 3, generates its contents on the fly, similar to a generator. This being the case, I would have expected the following line to take an inordinate amount of time because, in order to determine whether 1 quadrillion is in … Read more