-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
bpo-37319: Deprecated support of non-integer arguments in random.randrange(). #19112
bpo-37319: Deprecated support of non-integer arguments in random.randrange(). #19112
Conversation
I don't think this should be done. It churns an API that has been stable for two decades. It doesn't solve a real problem. It may break working code. It makes the code look gross. It will complicate maintenance. |
Looks like this is good to close from the discussion on https://bugs.python.org/issue37319 ? |
Reopened because @rhettinger just opened a duplicate issue. According to the same microbenchmark as in #23064, this PR provides a 10% speed up:
|
except TypeError: | ||
istep = int(step) | ||
if istep != step: | ||
raise ValueError("non-integer step for randrange()") |
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.
While we're at it, the exception type should be converted to TypeError.
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.
Should we raise it with custom message or reraise the exception raised by index()
?
@rhettinger, what are your problems with this PR? I addressed your comments, and would appreciate any other suggestions. |
I merged in PR 23064. If you want to make further modifications or improvements that would be welcome. |
9e238e7
to
5749575
Compare
I merged with master. Please make review. |
https://bugs.python.org/issue37319