Re:Python 3 Types in the Wild
by gnulinux on Friday March 18, 2022 @10:52AM
(#30723033)
Not only impossible in python, but also seems conceptually useless (why would you have a set of frozen sets?).
[ Parent
| on HN ]
Almost the entire purpose of frozensets was so that you could have sets of frozensets. It's the only way to have nested sets. Frozensets also work as dictionary keys.
Re:Python 3 Types in the Wild
by deltaonefour on Friday March 18, 2022 @11:42AM
(#30723658)
This is not useless. Why would you have a list of lists? A list is just an iterable container class, which is what a set is.
If the need exists for a list of lists then it exists for a set of sets.
An example of this is finding all combinations possible non ordered groups of letters given a collection of letters: abadfjiik.
A typical algorithm will produce dupes. But if your accumulator is a set of frozen sets you can produce a result with no dupes.
Ensure uniqueness, i guess? Though you'd lose that when you make the list of sets.
I could maybe see something like this as an intermediary result of parsing some horrible, nested obscure message format (except the dict, that baffles me unless the key-value types are reversed?)