biopython/biopython — pull request #248 by peterjc (2013-10-20 14:30:57+00:00)
Title: Adopt Python 3 style dictionary usage, disable 2to3 dict fixer

This change replaces our current Python 2 code like this:

values_as_list = my_dict.values()
for k, v in my_dict.iteritems():
print("key = %r, value = %r" % (key, value))

with Python 3 style code which will still work under Python 2:

my_keys_as_list = list(my_dict.values())
for k, v in my_dict.items():
print("key = %r, value = %r" % (key, value))

Essentially this is what the 2to3 dict fixer does, although that has a habit of adding too many list(...) wrappers.

The up side is this is then using dictionaries Python 3 style, we can disable the 2to3 dict fixer, and this is a (big) step towards a unified codebase which runs under both Python 2 and 3 unmodified.

The downside is the extra list(...) calls will give a slight performance hit under Python 2, and we're not getting the potential memory savings of using .itervalues, .iteritems etc. It is also possible I missed a few places where we need an extra list(...) for the code to work under Python 3 (any such cases lack unit tests and that should be addressed).