bpo-42222: Modernize integer test/conversion in randrange()#23064
Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Currently you are on the way to #19112 (which already has tests and documentation and cover corner cases).
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
Sorry, something went wrong.
|
I merged in the relevant parts of #19112. The principal differences are:
|
Sorry, something went wrong.
As in #19112 initially. I changed ValueError to TypeError on your request.
I would appreciate any suggestions to change wording.
Yes, tests in #19112 cover more cases.
As well as in #19112. But this PR still has issues. It does not emit warning for |
Sorry, something went wrong.
|
@rhettinger: Please replace |
Sorry, something went wrong.
Moves the
int(x) == xtest and conversion into the C code for operator.index().Provides a 7% speed up:
It should become even faster when we get a zero-cost try.
It's odd that non-integers raise a ValueError. I think that should have been TypeError.
https://bugs.python.org/issue42222