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-132108: Add Buffer Protocol support to int.from_bytes to improve performance#132109

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

Open
cmaloney wants to merge4 commits intopython:main
base:main
Choose a base branch
Loading
fromcmaloney:int_from_byteslike
Open
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
Tweak comments, fixPEP-7 formatting
  • Loading branch information
@cmaloney
cmaloney committedApr 22, 2025
commit9c511b15d0b4e717dacc6170f377b9cd23eeca79
6 changes: 4 additions & 2 deletionsObjects/longobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6453,12 +6453,14 @@ int_from_bytes_impl(PyTypeObject *type, PyObject *bytes_obj,
return NULL;
}

/*Use buffer protocol to avoid copies. */
/*Fast-path exact bytes. */
if (PyBytes_CheckExact(bytes_obj)) {
long_obj = _PyLong_FromByteArray(
(unsigned char *)PyBytes_AS_STRING(bytes_obj), Py_SIZE(bytes_obj),
little_endian, is_signed);
} else if (PyObject_CheckBuffer(bytes_obj)) {
}
/* Use buffer protocol to avoid copies. */
else if (PyObject_CheckBuffer(bytes_obj)) {
if (PyObject_GetBuffer(bytes_obj, &view, PyBUF_SIMPLE) != 0) {
return NULL;
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp