PEP 603 frozenmap VS my frozendict

I just created a version of mine of frozendict and I discovered that there’s a PEP discussing about a frozenmap.

There are some differences I’d like to discuss:

  1. the PEP propose to add it to collections module. IMHO for symmetry with set and frozenset, it should be added to builtins

  2. the PEP propose the introduction of frozenmap.including(key, value), frozenmap.excluding(key) and frozenmap.union(mapping=None, **kw) for creating new frozenmaps with new keys, updated keys or removed keys. On the contrary, my frozendict simply implements __add__() and __sub__(), so you can do, for example:

frozendict({"Sulla": "Marco", 2: 3}) + {"Sulla": "Marò", 4: 7, 5: 1}
# frozendict({'Sulla': 'Marò', 2: 3, 4: 7, 5: 1})

frozendict({"Sulla": "Marco", 2: 3}) - [2]
# frozendict({'Sulla': 'Marco'})
  1. The PEP propose a frozenmap.mutating() for returning a mutatable version of the frozenmap, that can be used in a context. What are the advantage against a simple dict(myfrozenmap)?

  2. The PEP does not want to preserve the insertion order, like dict does from CPython 3.6. Probably frozendict is much slower, since its implementation is in pure Python and it uses MappingProxyType, but at least the API is completely conformant to the dict API and insertion is preserved.

A post was merged into an existing topic: PEP-603: Adding a frozenmap type to collections