<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Sep 30, 2015 at 10:19 AM, Neil Girdhar <span dir="ltr"><<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I guess, I'm just asking for enumerate to go through the same change that range went through. Why wasn't it a problem for range?</div></blockquote><div><br></div><div>well, range is simpler -- you don't pass arbitrary iterables into it. It always has to compute integer values according to start, stop, step -- easy to implement as either iteration or indexing.</div><div><br></div><div>enumerate, on the other hand, takes an arbitrary iterable -- so it can't just index into that iterable if asked for an index.</div><div><br></div><div>You are right, of course, that it COULD do that if it was passed a sequence in the first place, but then you have an intera e whereby you get a different kind of object depending on how you created it, which is pretty ugly.</div><div><br></div><div>But again, we could add indexing to enumerate, and have it do the ugly inefficient thing when it's using an underlying non-indexable iterator, and do the efficient thing when it has a sequence to work with, thereby providing the same API regardless.</div><div><br></div><div>-CHB</div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div class="gmail_quote"><div dir="ltr">On Wed, Sep 30, 2015 at 1:18 PM Neil Girdhar <<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Ah good point. Well, in the case of a sequence argument, an enumerate object could be both a sequence and an iterator.<span style="line-height:1.5"> </span></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 30, 2015 at 1:15 PM Alexander Belopolsky <<a href="mailto:alexander.belopolsky@gmail.com" target="_blank">alexander.belopolsky@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 30, 2015 at 12:53 PM, Neil Girdhar <span dir="ltr"><<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">A Sequence is an Iterator.</blockquote></div><br></div></div><div dir="ltr"><div class="gmail_extra">No, a Sequence is an Iterable, not an Iterator:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">>>> issubclass(collections.Sequence, collections.Iterator)</div><div class="gmail_extra">False</div><div class="gmail_extra">>>> issubclass(collections.Sequence, collections.Iterable)</div><div class="gmail_extra">True</div></div></div>
</blockquote></div></blockquote></div>
</div></div><br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>