How is set() implemented?
Asked 07 September, 2021
Viewed 2.3K times
  • 57
Votes

I've seen people say that set objects in python have O(1) membership-checking. How are they implemented internally to allow this? What sort of data structure does it use? What other implications does that implementation have?

Every answer here was really enlightening, but I can only accept one, so I'll go with the closest answer to my original question. Thanks all for the info!

6 Answer