djangonauts / django-hstore

PostgreSQL HStore support for Django.
http://django-hstore.readthedocs.io/
Other
517 stars 142 forks source link

Replace iteritems with items #77

Closed vedgar closed 10 years ago

vedgar commented 10 years ago

There is no dict.iteritems in Py3. And in Py2, it really shouldn't make much of a performance difference to use dict.items.

coveralls commented 10 years ago

Coverage Status

Coverage remained the same when pulling b7b7c5a0a36b822dce70e56c5f728326f8015890 on vedgar:patch-1 into 08440e8768ead19ff5c2ad4444edf356b867f640 on djangonauts:master.

pashinin commented 10 years ago

https://pythonhosted.org/six/#six.iteritems I've ported some stuff with six pkg. Maybe you would like to consider using it (I find it quite nice)

vedgar commented 10 years ago

Yes, six is sometimes a necessary evil. But it always seemed to me like those horrible hacks when you write a file that's simultaneously a Bash script and a C++ program, or something like that. You simply write two different languages. I don't mean anything against people who write six, it is a wonderful package that is as nice as it can be considering the hard spec it must satisfy. But many times its power is not needed, like for example here. :-) If you want to evade performance penalty of dict.items on Py2, you can use parent dict.update(self, ...) directly (you can also use super, but be aware of its slightly different semantics on Py2 and Py3). On second look, I see that dict.py already uses six from django.utils. From the docs, it seems like it's the ordinary six with few enhancements, so if you imported it anyway, you might as well use it. :-) Your call. I only care that it works nicely with Py3.

pashinin commented 10 years ago

Just mentioned, if it is a small part of code and performance - you don't need six