PEP 802: Display Syntax for the Empty Set

Thank you for the reasoned feedback.

I’ve carefully avoided discussing performance, I don’t think it is a motivator for this change. Should we be inclined to do so, we could optimise {*()} or similar patterns into the BUILD_SET opcode today, without a PEP.

I think an improvement is that we would be able to make a statement in positive terms. We currently introduce set displays by saying “A set display is denoted by curly braces and distinguishable from dictionary displays by the lack of colons separating keys and values:”. We would be able to go on to say “An empty set is denoted by {/}, to distinguish it from the empty dictionary”, which follows on better in that section.

You make a reasonable point. Notably, this is why I rejected the {,} syntax. However, I think it’s surmountable – beginners need to learn other ‘special’ things, like that you write 2**3 instead of 2^3, or that ** means a different thing in function signatures. Beginners make mistakes all the time, so we could also add “did you mean” error messages for [/] and (/) to the parser to remind users that this is illegal syntax.

A

8 Likes