-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[mypyc] Add librt.random module #21433
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
Merged
Merged
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
6b52ec3
WIP librt.random
JukkaL 861b10f
Add random()
JukkaL 4051186
Add ChaCha8 RNG
JukkaL 1fb4997
Add module-level functions
JukkaL 4518d40
Add randrange
JukkaL 474c625
Support explicit seeds
JukkaL 34dd760
Use i64 as integer type
JukkaL fec5583
Add randbits62()
JukkaL db1e2d4
Add few Random primitives
JukkaL dc3b904
Add randbits62() primitive
JukkaL 22da84a
Unrelated: fix librt optimized build
JukkaL f7df2e8
Add primitive for random()
JukkaL 00c2e85
Addd randbits31()
JukkaL a0095a8
Primitives for randint and randrange
JukkaL c836447
Add more module level function primitives
JukkaL 9d82d78
Add more primitives
JukkaL 65109ce
Handle larger ranges better and improve error handling
JukkaL af12b54
Improve quality of random numbers
JukkaL 9703fdb
Add missing file
JukkaL 52d1406
Update api definition to match current approach
JukkaL cbe4c4b
Drop randbits31 and ranbits62 as low value
JukkaL 4841850
Add missing #include
JukkaL d6a3e5b
Fixes to large integer ranges
JukkaL 11b937f
Make Random final
JukkaL 125bdee
Improve error handling
JukkaL 0fde34c
Avoid the use of 128 bit integers for better portability
JukkaL 2e2925e
Minor fixes
JukkaL 062fa12
Lint
JukkaL 99fb114
Refactor tests
JukkaL 5a58dfc
Test calls using Any
JukkaL 17c2b17
Make get_thread_rng inline function
JukkaL 4137427
Don't put it behind experimental feature flag
JukkaL bd432db
Address code review
JukkaL 0124255
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from typing import final, overload | ||
|
|
||
| from mypy_extensions import i64 | ||
|
|
||
| def random() -> float: ... | ||
| def randint(a: i64, b: i64) -> i64: ... | ||
| @overload | ||
| def randrange(stop: i64, /) -> i64: ... | ||
| @overload | ||
| def randrange(start: i64, stop: i64, /) -> i64: ... | ||
| def seed(n: i64, /) -> None: ... | ||
|
|
||
| @final | ||
| class Random: | ||
| def __init__(self, seed: i64 | None = None) -> None: ... | ||
| def randint(self, a: i64, b: i64) -> i64: ... | ||
| @overload | ||
| def randrange(self, stop: i64, /) -> i64: ... | ||
| @overload | ||
| def randrange(self, start: i64, stop: i64, /) -> i64: ... | ||
| def random(self) -> float: ... | ||
| def seed(self, n: i64, /) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
the
_apifiles shouldn't be necessary when building the module as a shared library.