`Iter` benchmark

You got it! It’s an optimization.

When newer versions of CPython see you use a list in a way where there is no possible chance that it can be modified, or list methods called, the keyhole optimizer may replace it with a tuple instead.

Creating an empty tuple is cheaper than creating an empty list.

1 Like