Insert, remove and search values in constant time

myset = set()
 
myset.add(1)
myset.add(2)
# {1, 2}
 
print(len(myset)) # 2
print(1 in myset) # true
 
myset.remove(2)
print(2 in myset) # false

Initialising a hashset

# We can pass in an array
set([1, 2, 3])
 
# Set comprehension
myset = { i for i in range(5) }