-
Notifications
You must be signed in to change notification settings - Fork 963
add PyLong* API (3.14+)
#6016
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
Open
chirizxc
wants to merge
46
commits into
PyO3:main
Choose a base branch
from
chirizxc:PyLongWriter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add PyLong* API (3.14+)
#6016
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
7f623ee
add `PyLong*` API (3.14+)
chirizxc 59a6818
add newsfragments
chirizxc dce9996
cargo fmt
chirizxc 5e4018e
try fix
chirizxc 035b40e
fix typo (inr -> int)
chirizxc f2cebdc
try fix (x2)
chirizxc 0fb6575
fix clippy
chirizxc 05bfe1f
try fix clippy
chirizxc ebbb7da
add bench int 128
chirizxc 003647a
add tests
chirizxc 66b00a1
digits_ptr -> ptr
chirizxc b8b9597
review
chirizxc a089d89
cargo fmt
chirizxc e55d67e
fix
chirizxc a937d91
sync 3.14 (https://github.com/python/cpython/commit/af65a8be0c4f28a4b…
chirizxc 5e049e5
add `PyLong_Is*`
chirizxc 9ad8e5d
remove PyUnstable_Long_IsCompact
chirizxc e2c2caa
bench new line
chirizxc bf00a58
PyLong_FromUnicodeObject
chirizxc 14d54f3
remove #[cfg(not(Py_LIMITED_API))]
chirizxc 64248a1
review
chirizxc 884cd64
add 6016.changed.md
chirizxc 9618b36
update
chirizxc 4d4a0b0
update
chirizxc d96ca58
update
chirizxc 9976b33
fix
chirizxc f35bb45
fix
chirizxc 4a4855d
review
chirizxc 44861bd
review (x2)
chirizxc dd7f0dc
review (x3)
chirizxc e66b19c
add #[inline]
chirizxc e12e97b
update
chirizxc 66d063b
review
chirizxc 7fc518a
review (x2)
chirizxc 1cf84fe
fix
chirizxc 2bbc163
fix
chirizxc bd7af65
fmt
chirizxc 23af4f1
review
chirizxc 3d182b3
Merge branch 'main' into PyLongWriter
chirizxc a3041cf
review
chirizxc 84818b3
Merge branch 'main' into PyLongWriter
chirizxc ac81af8
std -> core
chirizxc 70d3985
std -> core (x2)
chirizxc 3fdcb06
review
chirizxc 2c6528a
review (x2)
chirizxc c2f8c9a
Update pyo3-ffi/src/cpython/longintrepr.rs
chirizxc 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 @@ | ||
| Added FFI wrappers for [PEP 757](https://peps.python.org/pep-0757/) `PyLong` import / export API on Python 3.14. |
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,55 @@ | ||
| use crate::{PyObject, Py_ssize_t}; | ||
| use core::ffi::{c_int, c_void}; | ||
|
|
||
| use crate::Py_uintptr_t; | ||
|
|
||
| // skipped PyLong_BASE | ||
| // skipped PyLong_MASK | ||
| // skipped _PyLong_New | ||
| // skipped _PyLong_Copy | ||
| // skipped _PyLong_FromDigits | ||
| // skipped _PyLong_SIGN_MASK | ||
| // skipped _PyLong_NON_SIZE_BITS | ||
| // skipped PyUnstable_Long_IsCompact | ||
| // skipped PyUnstable_Long_CompactValue | ||
|
|
||
| #[derive(Copy, Clone)] | ||
| #[repr(C)] | ||
| pub struct PyLongLayout { | ||
| pub bits_per_digit: u8, | ||
| pub digit_size: u8, | ||
| pub digits_order: i8, | ||
| pub digit_endianness: i8, | ||
| } | ||
|
|
||
| extern_libpython! { | ||
| pub fn PyLong_GetNativeLayout() -> *const PyLongLayout; | ||
| } | ||
|
|
||
| #[repr(C)] | ||
| pub struct PyLongExport { | ||
| pub value: i64, | ||
| pub negative: u8, | ||
| pub ndigits: Py_ssize_t, | ||
| pub digits: *const c_void, | ||
| _reserved: Py_uintptr_t, | ||
| } | ||
|
|
||
| extern_libpython! { | ||
| pub fn PyLong_Export(obj: *mut PyObject, export_long: *mut PyLongExport) -> c_int; | ||
| pub fn PyLong_FreeExport(export_long: *mut PyLongExport); | ||
| } | ||
|
|
||
| opaque_struct!(pub PyLongWriter); | ||
|
|
||
| extern_libpython! { | ||
| pub fn PyLongWriter_Create( | ||
| negative: c_int, | ||
| ndigits: Py_ssize_t, | ||
| digits: *mut *mut c_void, | ||
| ) -> *mut PyLongWriter; | ||
|
|
||
| pub fn PyLongWriter_Finish(writer: *mut PyLongWriter) -> *mut PyObject; | ||
|
|
||
| pub fn PyLongWriter_Discard(writer: *mut PyLongWriter); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.