Mar-28-2020, 06:54 PM
Pages: 1 2
Mar-28-2020, 07:02 PM
for one frozenset can be used as key in a dict. it's a direct result of frozenset being immutable. if you want to prevent set being changed- e.g. think of tuple vs list.
Mar-28-2020, 07:03 PM
Same as when you asked about tuples vs. lists - immutability is a good idea.
Mar-29-2020, 05:56 AM
then why is there no immutable equivalent to dictionary?
Mar-29-2020, 06:19 AM
there is, although as a third-party package on PyPI:
forzendict
As to why not in the Standard Library, read the rejected PEP 416
forzendict
As to why not in the Standard Library, read the rejected PEP 416
Apr-01-2020, 12:43 AM
OK, yeah, i can see many complications, now, like values have to be unchangeable and immutable.
Apr-14-2020, 12:41 PM
today I saw there is draft PEP 603 - Adding a frozenmap type to collections
It may be interesting to you in the light of the discussion above
It may be interesting to you in the light of the discussion above
Apr-14-2020, 07:55 PM
so a FrozenMapCopy does not actually change when modifications are applied, but a frozenmap created from a modified FrozenMapCopy reflects those changes?
i don't understand how can be passed to the frozenmap constructor; creating a frozenmap from a FrozenMapCopy object is an O(1) operation; can be O(1).
i don't understand how can be passed to the frozenmap constructor; creating a frozenmap from a FrozenMapCopy object is an O(1) operation; can be O(1).
Apr-14-2020, 08:01 PM
(Apr-14-2020, 07:55 PM)Skaperen Wrote: [ -> ]FrozenMapCopy does not actually change when modifications are applied,I think you misunderstood this part, it's the other way around - the frozenmap does not reflect the changes in FrozenMapCOpy
Quote:[FrozenMappCopy] are mutable, although any mutations on them do not affect the frozenmap instances they were created from;
Apr-14-2020, 08:25 PM
i'm not saying (the opposite of) that. i'm saying... modifications to FrozenMapCopy ...do not actually change that FrozenMapCopy (but instead record the modifications in a way that allows a new frozenmap created from it to be as if the frozenmap were mutable and copied). i get this from that example code (the big example after frozenmap.mutating()) that did
del copy[591221]
twice without an error.Pages: 1 2