Real Python Tutorials

Why Are Membership Tests So Fast for range() in Python?
NEW

Why Are Membership Tests So Fast for range() in Python?

In Python, range() is most commonly used in for loops. However, ranges have some other use cases too, as they share many properties with lists. In this tutorial, you'll explore why it's so fast to perform a membership test on a Python range.

Jun 28, 2023 data-structures intermediate