
Learn Python Programming
By :

Python also provides two set types, set
and frozenset
. The set
type is mutable, while frozenset
is immutable. They are unordered collections of immutable objects. When printed, they are usually represented as comma-separated values, within a pair of curly braces.
Hashability is a characteristic that allows an object to be used as a set member as well as a key for a dictionary, as we will see very soon.
From the official documentation (https://docs.python.org/3.12/glossary.html#term-hashable):
”An object is hashable if it has a hash value which never changes during its lifetime, and can be compared to other objects. […] Hashability makes an object usable as a dictionary key and a set member, because these data structures use the hash value internally. Most of Python’s immutable built-in objects are hashable; mutable containers (such as lists or dictionaries) are not; immutable containers (such as tuples and frozensets) are only hashable...