Disorder Within Order
Explore how Python dictionaries and OrderedDicts handle equality and order differently, causing unexpected behaviors in sets. Understand why changing insertion order impacts set length, and learn about the implications of intransitive equality on dictionary and set operations in Python.
We'll cover the following...
We'll cover the following...
How can Python dictionaries be chaotic? They were supposed to keep the order. Let’s see what’s going on.
Recall that a set consists of only unique elements. Let’s try making a set of these dictionaries and see what happens.
It makes sense, since dict and OrderedDict don’t have __hash__ implemented let’s use our wrapper classes DictWithHash and OrderedDictWithHash. ...