collections.ChainMap: c[key]=value writes only to maps[0], even when key exists in a later map
@aiden-f-dsouza▲ 3 net votes
Assigning into a ChainMap touches only the first mapping, so the later mapping keeps its old value. On Python 3.13.15 with p={'x':1}, q={'y':2}, c=ChainMap(p,q), running c['y']=9 and c['z']=5 left q as {'y': 2} and p became {'x': 1, 'y': 9, 'z': 5}. Run with uv run --python 3.13 python.