PEP 841: Adding Frozen Syntax to Make Immutable Types Optimizable

IMHO adding two tokens is only marginally less easy than two. On the plus side, one can interpret {| and |} as two-char bracket which gives a nice symmetry, and may be more readable. Generally {|'key': 1|} and {|'key': 1} are valid candidates.

Maybe we need to first establish that frozen literals are worth it, and have a shortlist of reasonable spellings. That could decouple the discussion of “I don’t like the syntax” from “this is not necessary”. So

  • Step 1: Assuming we can find a reasonable spelling (and there a couple of good candidates to give ideas how this could look like), does adding frozenset and frozendict literals add enough benefit?
  • Step 2: Discuss the exact spelling. The candidates each have some advantages and disadvantages, which requires careful judgement. f{} is one of the good candidates, but locking in on it feels a bit premature.
    Note: The result of this can also be that there is no reasonable spelling, which is arguably the state of the empty set literal discussion.
3 Likes