For those stumbling upon these answers from searching the web, know that they are relevant for Python 2. In Python 3, user created objects inherit __hash__
and __eq__
from python object
, which makes them hashable by identity, so set()
works by default for objects.