You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment futurize always adds a list constructor around python 3 iterators. Doing this creates a unnecessary copy in python 2, and an unnecessary list in python 3.
# currently
for k in d.keys():
pass
# becomes
for k in list(d.keys()):
pass
Because we are iterating there's no need to make this a list either in python 2 or python 3.
The text was updated successfully, but these errors were encountered:
Meanwhile, is it possible to disable the adding of list() altogether using --nofix? I tried disabling a lot of fixers but could not find the one that does this, and also I want to disable THIS behavior only, not other things the fixer might do. Indeed, I have taken the habit to write keys(), values() and items() with their Py3 behavior in mind, but futurize ALWAYS adds lists, even when unnecessary (which is the case for all my calls!), thus this fixer is only making my code consume more memory and more CPU time for nothing. A simple switch to disable this specific fix altogether (ie, never add list()) would tremendously help.
For those having the same issue as me, it's possible to disable the annoying adding of list() everywhere by using this nofix to the futurize call: futurize --grade2 --nofix lib2to3.fixes.fix_dict *.py
But then iteritems(), iterkeys() and itervalues() won't be converted automatically, so you have to manage that manually.
At the moment futurize always adds a list constructor around python 3 iterators. Doing this creates a unnecessary copy in python 2, and an unnecessary list in python 3.
Because we are iterating there's no need to make this a list either in python 2 or python 3.
The text was updated successfully, but these errors were encountered: