How would `list(d.values())` benefit from `__length_hint__`?

I just saw this new issue:

I was under the impression that list(...) already used __len__ as well and that dict and dict views already offer that. Where am I mistaken? How would adding __length_hint__ help there?

I think list(iterable) uses list_extend to get the elements into the list:

And list_extend uses PyObject_LengthHint:

And PyObject_LengthHint already tries __len__ first:

I wonder if this was overlooked or seen as not important.
If almost all use is as an iterator then its not needed.

I posted a link to this question on the issue.

Raymond closed the issue.

1 Like

Ok, thanks. I just felt it was way more likely that I was missing something, so I didn’t want to bother him there.