-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BEAM-1251] Migrate away from xrange() #4570
Conversation
It seems for most, if not all, of these uses of xrange, range would be perfectly acceptable as well (i.e. the ranges in question are quite small). Could you change these to use the vanilla range rather than import xrange from six? |
The lifetime of Python 2 is now just two years long. An alternative (probably safer) approach would be to leave this PRs as written until 2020 and then dropping Python 2 support will only require 1) removing the import and 2) doing a global find-and-replace of 'xrange(' --> 'range('. I am willing to go whichever way you feel is best. |
Unless there is a compelling reason to use xrange over range for any of these in Python 2 (I don't see one), let's change to range now. |
241be26
to
774fb62
Compare
I could not see any of these that I felt needed to be iterators in Python 2. Please let me know is you see any that could get massive. |
All look good to me. Will merge once all tests pass (not that I'm worried). |
@@ -21,7 +21,6 @@ | |||
import os.path | |||
import pickle | |||
import unittest | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint seems to want this newline.
e6eb12d
to
c635c63
Compare
@robertwb Is there something more that I need to do on this PR? |
xrange() was removed from Python 3 in favor of an iterator-based range().
For all files that use the Python 2-only builtin function xrange(), add the line from six.moves import xrange for compatibility with both Python 2 and Python 3.