<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Oct 4, 2014 at 3:27 PM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
</span>I don't understand this reasoning. Why do you think that they are<br>
unnecessary?</blockquote><div> </div></div>Sorry, that was a bad formulation. Obvisouly you need to increment a counter at some point when iterating over the generator.<br><br></div><div class="gmail_extra">Now, if you have a builtin function len (or other), you can define it to run a fast iterating loop using a C integer to maintain the number of elements during the loop. If you use sum(1 for a in  ...), I suppose there is some overhead due do the fact that you have to deal with Python objects when doing the additions.<br></div></div>