If you are interested in understanding how hash tables and the Set data structure are implemented in Python then you should check this article by Abhinav Upadhyay. He explained everything about the set implementation including the definition of the set object in CPython, Hash Collisions.