by rcfox · 6y ago · 0 comments
class OrderedDict(dict):
pass
(Plus a little bit of API shimming.)Further there is a big difference, regular dict preserves order across iteration but OrderedDict treats order up to equality.
I.e. this returns True:
{1: 1, 2: 2} == {2: 2, 1: 1}
Where as this returns False: OrderedDict({1: 1, 2: 2}) == OrderedDict({2: 2, 1: 1})
To make that difference speedy it needs to be done on the C level.For the latter issue, as explained above, can't they just implement a replacement __eq__ only for OrderedDict, and still re-use the new dict implementation?
Similarly, any subtle difference can be shimmed on top of the new implementation inside Python, no?