On Fri, Jan 21, 2022 at 3:52 AM Oscar Benjamin <oscar.j.benja...@gmail.com>
wrote:

>  > If this does all come to pass, then:
>>>  >
>>>  > s = {3,8,2}.frozen()
>>>  > will be slightly faster, in some case, than
>>>  > s = frozenset({3,8,2}
>>>  >
>>>  > but the result would be the same.
>>>
>>> I really don't understand (having read everything above) why anyone
> prefers {1,2,3}.frozen() over f{1,2,3}.
>

Because it doesn't require any change to the language -- it's a feature,
not a language change. Every change to the language is s substantial burden
to the whole community. Even a "small" one like this.

It was absolutely worth for, e.g. f-strings, because they are a
feature that has very broad use. This would have narrow use, and, I think
even the OP said is more about potential optimization than a nicer syntax.
If others think this syntax is substantially nicer, sure -- but then I'd
argue that frozensets are simply not that commonly used -- you yourself
realized that while you have an important use case, you aren't using
literals that often anyway (at all?).

Python is not a high-performance language -- has it ever had a feature
added primirly so it could be optimized? (that is a serious question).

And this does seem like a very small change, but is it?
1) folks, a couple years from now, reading new code might have never heard
of a frozenset, and see:

frozenset(something)
 or
{1,5,2}.frozen()

will probably have a pretty good idea what those mean, and if they have no
clue, then it's easy to look up.

f{3,1,6}

not so much.

And once we have ONE prefix on a bracket, I"ll bet you folks will suggest
more ...

small change
medium churn
tiny benefit

(frankly, it's confusing enough that {a,b,c} makes a set and {} makes a
dict, but what can we do? there's only so many brackets :-(

-CHB

-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/K2ZD7DV3YKQ4YURQXHM3PBJDORWQIGZ6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to