| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
| |
Reported by Svace static analyzer.
|
|
|
|
|
| |
Fix error messages for PySequence_Size(), PySequence_GetItem(),
PySequence_SetItem() and PySequence_DelItem() called with a mapping
and PyMapping_Size() called with a sequence.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
During development of the limited API support for PySide,
we saw an error in a macro that accessed a type field.
This patch fixes the 7 errors in the Python headers.
Macros which were not written as capitals were implemented
as function.
To do the necessary analysis again, a script was included that
parses all headers and looks for "->tp_" in serctions which can
be reached with active limited API.
It is easily possible to call this script as a test.
Error listing:
../../Include/objimpl.h:243
#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \
(Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o)))
Action: commented only
../../Include/objimpl.h:362
#define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
Action: commented only
../../Include/objimpl.h:364
#define PyObject_GET_WEAKREFS_LISTPTR(o) \
((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
Action: commented only
../../Include/pyerrors.h:143
#define PyExceptionClass_Name(x) \
((char *)(((PyTypeObject*)(x))->tp_name))
Action: implemented function
../../Include/abstract.h:593
#define PyIter_Check(obj) \
((obj)->ob_type->tp_iternext != NULL && \
(obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented)
Action: implemented function
../../Include/abstract.h:713
#define PyIndex_Check(obj) \
((obj)->ob_type->tp_as_number != NULL && \
(obj)->ob_type->tp_as_number->nb_index != NULL)
Action: implemented function
../../Include/abstract.h:924
#define PySequence_ITEM(o, i)\
( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) )
Action: commented only
|
|
|
|
|
| |
(GH-5222)
Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
|
| |
|
|
|
|
|
| |
This part of the PEP implementation adds support for
__mro_entries__ and __class_getitem__ by updating
__build_class__ and PyObject_GetItem.
|
|
|
|
| |
always return a list (#3840)
|
|
|
|
|
|
|
| |
* Add Py_UNREACHABLE() as an alias to abort().
* Use Py_UNREACHABLE() instead of assert(0)
* Convert more unreachable code to use Py_UNREACHABLE()
* Document Py_UNREACHABLE() and a few other macros.
|
|
|
|
|
|
|
| |
* group the (stateful) runtime globals into various topical structs
* consolidate the topical structs under a single top-level _PyRuntimeState struct
* add a check-c-globals.py script that helps identify runtime globals
Other globals are excluded (see globals.txt and check-c-globals.py).
|
| |
|
|
|
|
| |
(#2345)
|
|
|
|
|
|
| |
(#2325)
Prevent passing other invalid environment variables and command arguments.
|
|
|
|
|
|
| |
slots. (#700)
Negative result should be returned only when an error is set.
|
| |
|
|
|
|
|
|
|
|
|
| |
* Move all functions to call objects in a new Objects/call.c file.
* Rename fast_function() to _PyFunction_FastCallKeywords().
* Copy null_error() from Objects/abstract.c
* Inline type_error() in call.c to not have to copy it, it was only
called once.
* Export _PyEval_EvalCodeWithName() since it is now called
from call.c.
|
|
|
|
|
| |
Sorry, I didn't want to push this change before the review :-( I was pushing a
change into the 2.7 branch.
|
|
|
|
|
|
|
|
|
|
| |
* Move all functions to call objects in a new Objects/call.c file.
* Rename fast_function() to _PyFunction_FastCallKeywords().
* Copy null_error() from Objects/abstract.c
* Inline type_error() in call.c to not have to copy it, it was only
called once.
* Export _PyEval_EvalCodeWithName() since it is now called
from call.c.
|
|
|
|
| |
is_size_t test was reversed. Bug spotted by INADA Naoki.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Issue #29507: Optimize slots calling Python methods. For Python methods, get
the unbound Python function and prepend arguments with self, rather than
calling the descriptor which creates a temporary PyMethodObject.
Add a new _PyObject_FastCall_Prepend() function used to call the unbound Python
method with self. It avoids the creation of a temporary tuple to pass
positional arguments.
Avoiding temporary PyMethodObject and avoiding temporary tuple makes Python
slots up to 1.46x faster. Microbenchmark on a __getitem__() method implemented
in Python:
Median +- std dev: 121 ns +- 5 ns -> 82.8 ns +- 1.0 ns: 1.46x faster (-31%)
Co-Authored-by: INADA Naoki <songofacandy@gmail.com>
|
|
|
|
| |
Issue #29306: Destroy argstuple and kwdict if Py_EnterRecursiveCall() fails.
|
|
|
|
|
|
|
| |
* *PyCFunction_*Call*() functions now call Py_EnterRecursiveCall().
* PyObject_Call() now calls directly _PyFunction_FastCallDict() and
PyCFunction_Call() to avoid calling Py_EnterRecursiveCall() twice per
function call
|
|
|
|
|
| |
Remove two assertions which can fail on legit code. Keyword arguments are
checked later with better tests and raise a regular (TypeError) exception.
|
|
|
|
| |
Issue #29259.
|
|
|
|
| |
Issue #29259.
|
|
|
|
|
| |
Issue #29259. All other functions calling functions start with the similar
assertion.
|
|
|
|
| |
Issue ##27830, Issue #29259.
|
|
|
|
| |
Issue #29259.
|
|
|
|
|
| |
Issue #29286. Change _PyStack_UnpackDict() prototype to be able to notify of
failure when args is NULL.
|
|
|
|
| |
Issue #29286.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Issue #29234: Inlining _PyStack_AsTuple() into callers increases their stack
consumption, Disable inlining to optimize the stack consumption.
Add _Py_NO_INLINE: use __attribute__((noinline)) of GCC and Clang.
It reduces the stack consumption, bytes per call, before => after:
test_python_call: 1040 => 976 (-64 B)
test_python_getitem: 976 => 912 (-64 B)
test_python_iterator: 1120 => 1056 (-64 B)
=> total: 3136 => 2944 (- 192 B)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Issue #29233: Replace the inefficient _PyObject_VaCallFunctionObjArgs() with
_PyObject_FastCall() in call_method() and call_maybe().
Only a few functions call call_method() and call it with a fixed number of
arguments. Avoid the complex and expensive _PyObject_VaCallFunctionObjArgs()
function, replace it with an array allocated on the stack with the exact number
of argumlents.
It reduces the stack consumption, bytes per call, before => after:
test_python_call: 1168 => 1152 (-16 B)
test_python_getitem: 1344 => 1008 (-336 B)
test_python_iterator: 1568 => 1232 (-336 B)
Remove the _PyObject_VaCallFunctionObjArgs() function which became useless.
Rename it to object_vacall() and make it private.
|
|
|
|
| |
dict.
|
|
|
|
| |
Issue #27810.
|
|
|
|
|
|
|
|
|
| |
Issue #28870: Add a new _PY_FASTCALL_SMALL_STACK constant, size of "small
stacks" allocated on the C stack to pass positional arguments to
_PyObject_FastCall().
_PyObject_Call_Prepend() now uses a small stack of 5 arguments (40 bytes)
instead of 8 (64 bytes), since it is modified to use _PY_FASTCALL_SMALL_STACK.
|
|
|
|
|
| |
Issue #28915. Oops, I disabled the small stack to test both code paths. It's
now fixed.
|
|\ |
|
| | |
|
| |
| |
| |
| | |
Don't initialize variables which are not used before they are assigned.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Issue #28915: Replace PyObject_CallFunction() with
PyObject_CallFunctionObjArgs() when the format string was only made of "O"
formats, PyObject* arguments.
PyObject_CallFunctionObjArgs() avoids the creation of a temporary tuple and
doesn't have to parse a format string.
|
| |
| |
| |
| |
| | |
Issue #28915: Similar to _PyObject_CallFunctionObjArgs() but use va_list to
pass arguments.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Issue #28915: Use _Py_VaBuildStack() to build a C array of PyObject* and then
use _PyObject_FastCall().
The function has a special case if the stack only contains one parameter and
the parameter is a tuple: "unpack" the tuple of arguments in this case.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Issue #28915: Add _PyObject_CallFunctionVa() helper to factorize code of
functions:
* PyObject_CallFunction()
* _PyObject_CallFunction_SizeT()
* callmethod()
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Issue #28915: Add _PyObject_FastCallVa() helper to factorize code of functions:
* PyObject_CallFunctionObjArgs()
* PyObject_CallMethodObjArgs()
* _PyObject_CallMethodIdObjArgs()
Inline objargs_mkstack() into _PyObject_FastCallVa(), remove
objargs_mkstack().
|
| |
| |
| |
| |
| | |
_PyObject_FastCallKeywords() doesn't call _PyObject_FastCallDict() anymore:
call directly tp_call.
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
Replace:
PyObject_CallFunctionObjArgs(callable, NULL)
with:
_PyObject_CallNoArg(callable)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Issue #28838: Rename parameters of the "calls" functions of the Python C API.
* Rename 'callable_object' and 'func' to 'callable': any Python callable object
is accepted, not only Python functions
* Rename 'method' and 'nameid' to 'name' (method name)
* Rename 'o' to 'obj'
* Move, fix and update documentation of PyObject_CallXXX() functions
in abstract.h
* Update also the documentaton of the C API (update parameter names)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Replace
_PyObject_CallArg1(func, arg)
with
PyObject_CallFunctionObjArgs(func, arg, NULL)
Using the _PyObject_CallArg1() macro increases the usage of the C stack, which
was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this
issue.
|