On Mon, Jan 17, 2022 at 8:49 PM Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Mon, Jan 17, 2022 at 08:04:50PM +0900, Inada Naoki wrote:
>
> > Name lookup is faster than building set in most case.
> > So I don't think cost to look name up is important at all.
>
> But the cost to look up the name is *in addition* to building the set.
>

I meant it is negligible so we can just ignore it while this discussion.

> If you saw this code in a review:
>
>     t = tuple([1, 2, 3, 4, 5])
>
> would you say "that is okay, because the name lookup is smaller than the
> cost of building the list"?
>
> I wouldn't. I would change the code to `(1, 2, 3, 4, 5)`.
>

* I never said it. I just said just lookup cost is not good reason
because you listed name lookup cost for rationale. Please stop
strawman.
* tuple construction is much faster than set construction. So name
lookup speed is more important for tuple.
* Constant tuple is much much frequently used than constant set.

>
> > Proposed literal might have significant efficiency benefit only when:
> >
> > * It is used in the function scope. and,
> > * It can not be optimized by the compiler now.
>
> Sometimes, now, the compiler *pessimizes* the construction of the frozen
> set. See b.p.o #46393.
>

I saw. And I know all the discussions in the b.p.o. already.
But how important it is for Python depends on how often it is used,
especially in hot code.

Regards,

-- 
Inada Naoki  <songofaca...@gmail.com>
_______________________________________________
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/DSUYXZBLQ62MMRUYJ2ZNLDXYSEEOGDHW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to