
Jan. 21, 2022
1:57 a.m.
On Fri, Jan 21, 2022 at 11:18:27AM +1100, Cameron Simpson wrote:
Paired with a __freeze__ dunder method, this applies to any type, not just sets. (Where appropriate of course.)
So:
|{1,2,3}| frozen set |[1,2,3]| tuple! |any-iterable| tuple! |{1:2, 3:4}| frozen dict
A frozen "any iterable" is not necessarily a tuple. For example, a frozen binary tree should probably keep the tree structure and methods; a frozen dict.keys() should be a frozen set; and its not clear what a frozen iterator should do. Should it run the iterator to exhaustion? Seems odd. What about non-collections? What's a frozen re.MatchObject? -- Steve