-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Description
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. Since Py_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 example Py_BuildValue("i", x) can be replaced with PyLong_FromLong((int)x) or simply PyLong_FromLong(x), Py_BuildValue("(OO)", x, y) can be replaced with PyTuple_Pack(2, x, y).
Linked PRs
sunmy2019
Metadata
Metadata
Assignees
Labels
No labels