There is some indications in PEP 424: A method for exposing a length hint:
CPython currently defines a length_hint method on several types,
such as various iterators. This method is then used by various other
functions (such as list) to presize lists based on the estimate
returned by length_hint. Types which are not sized, and thus
should not define len, can then define length_hint, to allow
estimating or computing a size (such as many iterators).
And:
Being able to pre-allocate lists based on the expected size, as
estimated by length_hint, can be a significant optimization.
CPython has been observed to run some code faster than PyPy, purely
because of this optimization being present.
So it seems that list
calls __len__
in order to pre-allocate the list. Your list can grow as large as it wants after that.