On 21Jan2022 12:22, Ben Rudiak-Gould <[email protected]> wrote:
>There seem to be two different reasons people want a generic freeze syntax:
>
>1. Making a hashable copy of an arbitrary object
>
>2. Avoiding O(n) rebuilding of literals on every use (a constant for
>bytecode, as you put it)
The purpose of the operator (aside from genericity) was to enable
expression inspection by the compiler so that it can do for "|{1,2,3}|"
what it already does for "x in {1,2,3}".
The "generic" side to the operator approach was to provide a "freeze"
protocol one could use for generic objects.
>In both 1 and 2, not only the object but all of its children need to be
>immutable.
This is not strictly true. My own notion was a "shallow" freeze, not a
recursive freeze. For hashability, provided the hash and equality tests
only consider the frozen components, there's no need for a deep freeze -
just a frezze of the relevant aspects.
Cheers,
Cameron Simpson <[email protected]>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/K4TFYDV47M73GSGFHOUTXHQ7MLJE727C/
Code of Conduct: http://python.org/psf/codeofconduct/