>> This optimization also can be used for BUILD_TUPLE opcode and in pickle module, if it's OK to add _PyTuple_StealFromArray() function :-)
> I would like to see a micro-benchmark showing that it's faster.
+-----------------+-----------------+-----------------------------+
| Benchmark | build_tuple_ref | build_tuple_untracked |
+=================+=================+=============================+
| (a, ) | 19.9 ns | 19.4 ns: 1.03x faster (-3%) |
+-----------------+-----------------+-----------------------------+
| (a, 1) | 24.0 ns | 22.6 ns: 1.06x faster (-6%) |
+-----------------+-----------------+-----------------------------+
| (a, 1, 1) | 28.2 ns | 25.9 ns: 1.09x faster (-8%) |
+-----------------+-----------------+-----------------------------+
| (a, 1, 1, 1) | 31.0 ns | 29.0 ns: 1.07x faster (-6%) |
+-----------------+-----------------+-----------------------------+
| (a, 1, 1, 1, 1) | 34.7 ns | 32.2 ns: 1.08x faster (-7%) |
+-----------------+-----------------+-----------------------------+ |