Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-42222: Modernize integer test/conversion in randrange()#23064

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
rhettinger merged 9 commits intopython:masterfromrhettinger:fast_randrange
Dec 28, 2020

Conversation

rhettinger
Copy link
Contributor

@rhettingerrhettinger commentedOct 31, 2020
edited by bedevere-bot
Loading

Moves theint(x) == x test and conversion into the C code foroperator.index().

Provides a 7% speed up:

$ pytime -s 'from random import randrange' 'randrange(15)'  # baseline500000 loops, best of 11: 540 nsec per loop$ pytime -s 'from random import randrange' 'randrange(15)'   # new versio500000 loops, best of 11: 502 nsec per loop

It should become even faster when we get a zero-costtry.

It's odd that non-integers raise aValueError. I think that should have beenTypeError.

https://bugs.python.org/issue42222

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Currently you are on the way to#19112 (which already has tests and documentation and cover corner cases).

@github-actions
Copy link

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

@github-actionsgithub-actionsbot added the staleStale PR or inactive for long period of time. labelDec 16, 2020
@rhettingerrhettinger removed the staleStale PR or inactive for long period of time. labelDec 24, 2020
@serhiy-storchaka
Copy link
Member

What about#19112?

@rhettinger
Copy link
ContributorAuthor

I merged in the relevant parts of#19112. The principal differences are:

  • TheTypeError won't start being emitted until the after the deprecation period.
  • Improved wording for the doc entries.
  • Tests focus solely on the deprecations.
  • All existing behavior remains intact until after the deprecation.

@serhiy-storchaka
Copy link
Member

  • TheTypeError won't start being emitted until the after the deprecation period.

As in#19112 initially. I changed ValueError to TypeError on your request.

  • Improved wording for the doc entries.

I would appreciate any suggestions to change wording.

  • Tests focus solely on the deprecations.

Yes, tests in#19112 cover more cases.

  • All existing behavior remains intact until after the deprecation.

As well as in#19112.

But this PR still has issues. It does not emit warning forrandrange(10, 20, 1.0).

@rhettingerrhettinger merged commita9621bb intopython:masterDec 28, 2020
@bedevere-bot
Copy link

@rhettinger: Please replace# withGH- in the commit message next time. Thanks!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

@tim-onetim-oneAwaiting requested review from tim-one

Assignees
No one assigned
Labels
performancePerformance or resource usage
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@rhettinger@serhiy-storchaka@bedevere-bot@the-knights-who-say-ni

[8]ページ先頭

©2009-2025 Movatter.jp