Python sets, frozensets, and literals
Python sets, frozensets, and literals
Posted Jan 20, 2022 18:48 UTC (Thu) by JoeBuck (subscriber, #2330)In reply to: Python sets, frozensets, and literals by quietbritishjim
Parent article: Python sets, frozensets, and literals
But it probably isn't a good idea, because it could be unexpectedly expensive: people expect hashes to be fast, and if we're always doing copy-and-insert, copy-and-hash it would be costly.
Posted Jan 20, 2022 23:08 UTC (Thu)
by quietbritishjim (subscriber, #114117)
[Link]
> If you copy the set into a frozenset then changes to X won't be reflected in the new location - very confusing.
I think the fact that changes to the original set won't be reflected in the frozenset made from it earlier is even more serious than the cost of the copy.
Python sets, frozensets, and literals