On 04Jan2022 21:03, Marco Sulla <marco.sulla.pyt...@gmail.com> wrote: >On Tue, 4 Jan 2022 at 19:38, Chris Angelico <ros...@gmail.com> wrote: >> [...] should the keys view be considered >> frozen or not? Remember the set of keys can change (when the >> underlying dict changes). > >Well, also the items can change, but they are returned as tuples with >2 elements. > >It seems to me that the stdlib, when something should return a >sequence, prefers to return a tuple. So I expected the same preference >for frozenset over set. > >> It's not difficult to construct a frozenset from a set. > >This sentence has the commutative property :)
Indeed. But speaking for myself, I may well want to perform additional work on the object returned. Making a copy of it for tht purpose seems very wasteful (imagine the set is quite large). A modifiable version can be used immediately with no time or space cost. And it can be left alone if it is to be unchanged. If I got a frozenset back I would inherently have to copy it to do "modifying work". So I prefer getting a modifiable object back. Cheers, Cameron Simpson <c...@cskk.id.au> -- https://mail.python.org/mailman/listinfo/python-list