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.

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)`.


> 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.


-- 
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/NJZJI5G5FNPSBH2WTJWGTCHHCFB4WEM3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to