Hashable Objects in Python Mutable
objects are not hashable. You might ask why. Hash function usually
depend on object state. So if state changes, the hash function
could change, violating the consistency specification. How do you
see if something is hashable? Call the hash
function
on it.
Sets
Primtive notion: x ∈ A Specify a set iwth a list {3, "cat", True, 4.5} Or with a rule: {x an integer, x%2 == 0} (even integers)
Stupid Set (You will later write this in Java)
Great idea: start up a list presented with new element, we check the list for element's presence (this is O(n) "at worst proprotional to n") if found: ignore it if not found: add it to the list.`A Little Math
Hashing and Sets Here is why retrieval from a set is fast.
A ∪ B = union A ∩ B = intersectionDictionaries