
Why does it need to be called at all? {1, 2, 3}.frozen Or even: {1, 2, 3}.f On Wed, Jan 19, 2022, 6:28 AM Steven D'Aprano <steve@pearwood.info> wrote:
On Wed, Jan 19, 2022 at 07:20:12AM +0000, Ben Rudiak-Gould wrote:
My preferred syntax for a frozenset literal would be something like
{1, 2, 3}.freeze()
This requires no new syntax, and can be safely optimized at compile time (as far as I can tell).
I like that, it is similar to a proposal for docstrings:
https://bugs.python.org/issue36906
This would be safe to optimize at compile time, so long as the contents of the set were all literals. And for implementations that didn't optimize at compile time, it would be no worse than the situation now.
Perhaps a better name would be "frozen()` since that doesn't imply an in-place operation like "freeze" does.
-- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/B3GTIX... Code of Conduct: http://python.org/psf/codeofconduct/