<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 16, 2014 at 2:45 AM, Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">Iterating accross a dictionary doesn't need compatibility shims. It's<br>
dead simple in all Python versions:<br>
<br>
$ python2<br>
Python 2.7.8 (default, Oct 20 2014, 15:05:19)<br>
[GCC 4.9.1] on linux2<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> d = {'a': 1}<br>
>>> for k in d: print(k)<br>
...<br>
a<br>
<br>
$ python3<br>
Python 3.4.2 (default, Oct 8 2014, 13:08:17)<br>
[GCC 4.9.1] on linux<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> d = {'a': 1}<br>
>>> for k in d: print(k)<br>
...<br>
a<br>
<br>
Besides, using iteritems() and friends is generally a premature<br>
optimization, unless you know you'll have very large containers.<br>
Creating a list is cheap.<br></div></blockquote><div><br></div><div>It seems to me that every time I hear this, the author is basically admitting that Python is a toy language not meant for "serious computing" (where serious is defined in extremely modest terms). The advice is also very contradictory to literally every talk on performant Python that I've seen at PyCon or PyData or ... well, anywhere. And really, doesn't it strike you as incredibly presumptuous to call the *DEFAULT BEHAVIOR* of Python 3 a "premature optimization"? Isn't the whole reason that the default behavior switch was made is because creating lists willy nilly all over the place really *ISN'T* cheap? This isn't the first time someone has tried to run this line past me, but it's the first time I've been fed up enough with the topic to call it complete BS on the spot. Please help me stop the community at large from saying this, because it really isn't true at all.</div><div><br></div></div></div><div class="gmail_extra">-Mark</div></div>