-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Replace trivial Py_BuildValue() with direct C API call #110093
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
Comments
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Sep 29, 2023
serhiy-storchaka
added a commit
that referenced
this issue
Oct 20, 2023
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this issue
Oct 20, 2023
serhiy-storchaka
added a commit
that referenced
this issue
Oct 20, 2023
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Feb 11, 2024
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this issue
Sep 2, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Py_BuildValue()
is a powerful tool which can be used to create complex Python structures. But in some cases it is used to create a Python objects from a C value for which a special C API exists. SincePy_BuildValue()
adds some overhead (parsing the format string, copying va_list, several levels of recursive calls), it is less efficient than direct call of the corresponding C API. For examplePy_BuildValue("i", x)
can be replaced withPyLong_FromLong((int)x)
or simplyPyLong_FromLong(x)
,Py_BuildValue("(OO)", x, y)
can be replaced withPyTuple_Pack(2, x, y)
.Linked PRs
The text was updated successfully, but these errors were encountered: