
Jan. 17, 2022
11:42 a.m.
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