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

gh-133489: Remove size restrictions on getrandbits() and randbytes()#133658

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

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedMay 8, 2025
edited by bedevere-appbot
Loading

random.getrandbits() can now generate more that 2**31 bits. random.randbytes() can now generate more that 256 MiB.

…tes()random.getrandbits() can now generate more that 2**31 bits.random.randbytes() can now generate more that 256 MiB.
@@ -806,6 +806,20 @@ def test_getrandbits(self):
self.assertEqual(self.gen.getrandbits(100),
97904845777343510404718956115)

def test_getrandbits_2G_bits(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be decorated with bigmemtest? Ditto the second test.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It requires only 800 MB of memory. Too small for bigmemtest. The second test requires about 1300 MB of memory. This may be too small too, but I'm going to add bigmemtest after testing on 32-bit buildbots.

Copy link
Contributor

Choose a reason for hiding this comment

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

It requires only 800 MB of memory. Too small for bigmemtest.

Where is the boundary? IIRC, memory limit is configurable.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It was 1GiB (you could not specify less than 1 GiB for -M option in regrtest). But now it seems is 2 GiB.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Actually, it was initially 2.5 GiB, then lowered to 2 GiB. But I add bigmemtest even for some tests that need 1-2 GiB.

gpshead reacted with thumbs up emoji
@serhiy-storchaka
Copy link
MemberAuthor

!buildbot 32

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@serhiy-storchaka for commit24cbd8d 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F133658%2Fmerge

The command will test the builders whose names match following regular expression:32

The builders matched are:

  • wasm32 WASI 8Core PR
  • wasm32-wasi PR
  • wasm32-wasi Non-Debug PR

@serhiy-storchaka
Copy link
MemberAuthor

!buildbot android

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@serhiy-storchaka for commit24cbd8d 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F133658%2Fmerge

The command will test the builders whose names match following regular expression:android

The builders matched are:

  • AMD64 Android PR
  • aarch64 Android PR

Copy link
Member

@gpsheadgpshead left a comment

Choose a reason for hiding this comment

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

also consider tagging any of the new tests that take a long time to run (especially from a GH CI perspective) as@support.requires_resource("cpu").

@serhiy-storchaka
Copy link
MemberAuthor

The new non-bigmem test takes 1 second on my computer. I usually only mark tests that take more than 5 seconds.

Slowest test durations----------------------------------------------------------------------1.058s     test_getrandbits_2G_bits (test.test_random.MersenneTwister_TestBasicOps.test_getrandbits_2G_bits)1.030s     test_binomialvariate (test.test_random.TestDistributions.test_binomialvariate)0.623s     test_bug_9025 (test.test_random.SystemRandom_TestBasicOps.test_bug_9025)0.258s     test_bug_9025 (test.test_random.MersenneTwister_TestBasicOps.test_bug_9025)0.132s     test_choices_algorithms (test.test_random.MersenneTwister_TestBasicOps.test_choices_algorithms)----------------------------------------------------------------------

@serhiy-storchakaserhiy-storchaka added needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsMay 31, 2025
@serhiy-storchakaserhiy-storchaka merged commit68784fe intopython:mainMay 31, 2025
43 checks passed
@miss-islington-app
Copy link

Thanks@serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@serhiy-storchakaserhiy-storchaka deleted the random-getrandbits-2Gbits branchMay 31, 2025 08:23
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 31, 2025
…tes() (pythonGH-133658)random.getrandbits() can now generate more that 2**31 bits.random.randbytes() can now generate more that 256 MiB.(cherry picked from commit68784fe)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@miss-islington-app
Copy link

Sorry,@serhiy-storchaka, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 68784fed78aa297f0de0d038742495709185bef5 3.13

@bedevere-app
Copy link

GH-134964 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelMay 31, 2025
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull requestMay 31, 2025
… randbytes() (pythonGH-133658)random.getrandbits() can now generate more that 2**31 bits.random.randbytes() can now generate more that 256 MiB.(cherry picked from commit68784fe)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link

GH-134965 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelMay 31, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@skirpichevskirpichevskirpichev left review comments

@gpsheadgpsheadgpshead approved these changes

@rhettingerrhettingerAwaiting requested review from rhettingerrhettinger is a code owner

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@serhiy-storchaka@bedevere-bot@gpshead@skirpichev

[8]ページ先頭

©2009-2025 Movatter.jp