<div dir="ltr"><div>Support for len() on iterators isn't going to happen.<br><br>The "gut feeling" reason is that len() shouldn't "consume" anything. It would lure people into thinking they can first call len() on the iterator and then iterate over it -- while, if it is an actual iterator (like an I/O stream), after calling len(), everything is consumed.<br><br>Yes, it's possible that you only want to count the number of lines, but that's unusual, and the idiom for that is readily available (e.g. sum(1 for ...)). If the idiom occurs frequently in your code you can define a helper function count(). The speed benefit of doing the loop in C would be minimal in most cases.<br></div><br><div><div class="gmail_extra">-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)
</div></div></div>