PEP 841: Adding Frozen Syntax to Make Immutable Types Optimizable#5049
PEP 841: Adding Frozen Syntax to Make Immutable Types Optimizable#5049corona10 wants to merge 7 commits into
Conversation
Documentation build overview
10 files changed ·
|
| This was rejected because most symbols already have a meaning as operators. | ||
| We can't reuse them for this new purpose. | ||
| We also don't want to add new symbols like ``$`` | ||
| to keep them for something else in the future. |
There was a problem hiding this comment.
I must confess I'm slightly surprised to see direct mention here about the risk of monopolizing symbols such as $ in case they might be of value in the future -- and yet no mention of using { itself in a context which was previously available and could have been used to good effect.
In particular since this PEP is all about adding constant folding opportunities for exactly two built-in functions -- just to make the functions tempting enough to make people more liable to use them -- the fact that the proposal locks down some syntax forever to mean this one thing, is something I really would expect to see justified.
There was a problem hiding this comment.
@sobolevn We may need to revise this section. Thank you @eli-schwartz
There was a problem hiding this comment.
And for context, an example of something the PEP could argue against -- the PEP I'd probably write, if I had the time / sponsorship -- would be to solve the problem of "builtins cannot be unambiguously referenced after being overwritten / reused as a kwarg, and even import builtins; builtins.int can't definitely get you one. Nor can type(1) or builtins.type(1), to say nothing of builtins that aren't for classes with dedicated syntax". And not that any of these are actually good ways to achieve said goal!
The obvious thing that springs to mind for using f{}, aside for "f-sets", is func{arg1} as a guaranteed builtin with no name lookups, which means we can reimplement this PEP as frozenset{ {'data'} }. The optimization opportunities are identical, but more extensive as now all other builtin functions are in scope.
(This is basically why I dislike the PEP itself -- it feels like "thinking small" / not very imaginative about pushing the boundaries of python.)
There was a problem hiding this comment.
@eli-schwartz this is not really a place for technical discusions, let's please move to https://discuss.python.org/t/pep-841-adding-frozen-syntax-to-make-immutable-types-optimizable/108219/32 for better visibility :)
Basic requirements (all PEP Types)
pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) andPEPheaderuvx pepotron next(orpipx install pepotronthenpep next)AuthororSponsor, and formally confirmed their approvalAuthor,Status(Draft),TypeandCreatedheaders filled out correctlyPEP-Delegate,Topic,RequiresandReplacesheaders completed if appropriate.github/CODEOWNERSfor the PEPStandards Track requirements
Python-Versionset to valid (pre-beta) future Python version, if relevantDiscussions-ToandPost-History