Skip to content

gh-128213: fast path for bytes creation from list and tuple #132590

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
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 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
Prev Previous commit
Next Next commit
revert to PyLong_AsLongAndOverflow for easier overflow handling
  • Loading branch information
blhsing committed Dec 25, 2024
commit 4e1e3e6bb9c3d2ce6c565070a3fc1cfc769fa9f8
3 changes: 2 additions & 1 deletion Objects/bytesobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2828,7 +2828,8 @@
bytes = Py_None;
goto done;
}
int value = PyLong_AsInt(items[i]);
int overflow;
long value = PyLong_AsLongAndOverflow(items[i], &overflow);
if (value == -1 && PyErr_Occurred()) {
goto error;
}
Expand All @@ -2844,9 +2845,9 @@
error:
Py_DECREF(bytes);
bytes = NULL;
done:

Check failure on line 2848 in Objects/bytesobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer (ubuntu-24.04)

label at end of compound statement
/* both success and failure need to end the critical section */
Py_END_CRITICAL_SECTION_SEQUENCE_FAST();

Check failure on line 2850 in Objects/bytesobject.c

View workflow job for this annotation

GitHub Actions / Windows / build and test (arm64)

syntax error: missing ';' before '}' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2850 in Objects/bytesobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (arm64)

syntax error: missing ';' before '}' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2850 in Objects/bytesobject.c

View workflow job for this annotation

GitHub Actions / Windows / build and test (x64)

syntax error: missing ';' before '}' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 2850 in Objects/bytesobject.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (x64)

syntax error: missing ';' before '}' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]
return bytes;
}

Expand Down
Loading