Closed vedgar closed 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)
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.
Just mentioned, if it is a small part of code and performance - you don't need six
There is no
dict.iteritems
in Py3. And in Py2, it really shouldn't make much of a performance difference to usedict.items
.