1. Introduction
Potentially complete core container set:
list
&tuple
set
&frozenset
dict
&frozendict
Given the above, these are “missing”:
set
- no empty set literalfrozenset
- object exists, but nothing elsefrozendict
- nothing exists, not even the object
To address (1), there are couple of threads:
To address (2), has been one attempt (as far as I know):
To address (3), the first step of object creation:
- PEP 603: Adding a frozenmap type to collections
- I think there have been more attempts, but it is not relevant to this thread.
2. Consideration
(1) above is just for complete picture, but this is mostly about (2) and (3).
My thought process:
- So (2) was attempted and proved to be tricky (at least that specific solution).
- If
frozendict
was implemented, then instead of 1 full set of literals/comprehensions, 2 are lacking. And even one seems to be difficult. - Thus, maybe what could work is something similar to “string type prefixes”?
Given set literal exists. E.g. {/}
:
{/} # Empty Set
f{/} # Empty Frozen Set
{} # Empty Dict
f{} # Empty Frozen Dict
{a for a in iterable} # set
f{a for a in iterable} # frozenset
{a: b for a, b in iterable} # dict
f{a: b for a, b in iterable} # frozendict
Not necessarily f
, but the idea is not to make up new brackets
, but instead use the same syntax, but with some frozen
indicator. Maybe prefix, maybe suffix, maybe something else entirely.
3. To sum up
If frozendict
is indeed coming and comprehensions for both frozenset
and frozendict
are desirable, then solution that would capture comprehensions/literals for them both while drawing sensible/consistent parallels could be convenient/smooth path forward.
Thoughts?