>
> Also, it is standard in Python to avoid properties if the computation
> could be expensive. Copying a large set or millions of elements into a
> frozenset could be expensive, so we should keep it a method call.


Here is another hint that this usage would not resolve the problem of
having a literal frozenset. Even in the core of this discussion, with folks
participating and knowing what they are talking about, the first thing that
comes to mind when seeing a method call is that the target set would
be copied. The messages are just about no-need to copy this
into a frozenset.

But upon seeing a method call, we can just think first of a runtime behavior
Correctly, btw. Any optimization there would be an exception, that people
would
have to know by heart.

On Wed, Jan 19, 2022 at 10:31 AM Steven D'Aprano <st...@pearwood.info>
wrote:

> On Wed, Jan 19, 2022 at 07:12:04AM -0500, Ricky Teachey wrote:
> > Why does it need to be called at all?
> >
> > {1, 2, 3}.frozen
>
> For the same reason that most methods are methods, not properties.
>
> The aim of a good API is not to minimize the amount of typing, it is to
> communicate the *meaning* of the code as best as possible.
>
> `{1, 2, 3}.frozen` says that the result is an attribute (property,
> member) of the set. Like *name* to a person, or *tail* to a dog, the
> attribute API represents something which is part of, or a quality of,
> the object. The frozenset is not an attribute of the set, it is a
> transformation of the set into a different type.
>
> A transformation should be written as an explicit function or method
> call, not as attribute access. Yes, we can hide that transformation
> behind a property just to save typing two characters, but that is an
> abuse of notation.
>
> Also, it is standard in Python to avoid properties if the computation
> could be expensive. Copying a large set or millions of elements into a
> frozenset could be expensive, so we should keep it a method call.
>
>
> --
> Steve
> _______________________________________________
> 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/WS5IXNJKETM5JICWCYJPDOF2HNK75DNK/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
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/T55L2JOA6PVHV473RHYU45SQOHHH3IHQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to