| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
(GH-6030)
METH_NOARGS functions need only a single argument but they are cast
into a PyCFunction, which takes two arguments. This triggers an
invalid function cast warning in gcc8 due to the argument mismatch.
Fix this by adding a dummy unused argument.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix clang ubsan (undefined behavior sanitizer) warnings in dictobject.c by
adjusting how the internal struct _dictkeysobject shared keys structure is
declared.
This remains ABI compatible. We get rid of the union at the end of the
struct being used for conveinence to avoid typecasting in favor of char[]
variable length array at the end of a struct. This is known to clang to be
used for variable sized objects and will not cause an undefined behavior
problem. Similarly, char arrays do not have strict aliasing undefined
behavior when cast.
PEP-007 does not currently list variable length arrays (VLAs) as allowed
in our subset of C99. If this turns out to be a problem, the fix to this is
to change the char `dk_indices[]` into `dk_indices[1]` and restore the
three size computation subtractions this change removes:
`- Py_MEMBER_SIZE(PyDictKeysObject, dk_indices)`
If this works as is I'll make a separate PR to update PEP-007.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
dictview_repr(): Use a Py_ReprEnter() / Py_ReprLeave() pair to check
for recursion, and produce "..." if so.
test_recursive_repr(): Check for the string rather than a
RecursionError. (Test cannot be any tighter as contents are
implementation-dependent.)
test_deeply_nested_repr(): Add new test, replacing the original
test_recursive_repr(). It checks that a RecursionError is raised in
the case of a non-recursive but deeply nested structure. (Very
similar to what test_repr_deep() in test/test_dict.py does for a
normal dict.)
OrderedDictTests: Add new test case, to test behavior on OrderedDict
instances containing their own values() or items().
|
|
|
|
|
| |
(GH-5222)
Add two new private APIs: _PyObject_LookupAttr() and _PyObject_LookupAttrId()
|
| |
|
|
|
|
|
| |
Silence only AttributeError when get "key" and "items" attributes in
the constructor and the update() method of dict and OrderedDict .
|
| |
|
|
|
|
|
|
|
| |
* 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).
|
| |
|
|
|
|
| |
* remove hashpos parameter from lookdict functions.
* remove many duplicated code from lookdict functions.
|
|
|
|
|
| |
the bare METH_FASTCALL be used for functions with positional-only
parameters.
|
|
|
| |
replace `(i << 2) + 1` with `i*5`
|
| |
|
|
|
|
| |
Based on patches by Duane Griffin and Tim Mitchell.
|
|
|
|
|
|
|
|
| |
Make a non-Py_DEBUG, asserts-enabled build of CPython possible. This means
making sure helper functions are defined when NDEBUG is not defined, not
just when Py_DEBUG is defined.
Also fix a division-by-zero in obmalloc.c that went unnoticed because in Py_DEBUG mode, elsize is never zero.
|
| |
|
|
|
|
| |
lookdict_unicode() and lookdict_unicode_nodummy() may raise exception
when key is not unicode.
|
| |
|
| |
|
|
|
|
| |
methods.
|
|
|
|
| |
"default".
|
|
|
|
| |
Issue #29312.
|
|
|
|
|
|
|
|
|
|
|
| |
Issue #29311: dict.get() and dict.setdefault() methods now use Argument Clinic
to parse arguments. Their calling convention changes from METH_VARARGS to
METH_FASTCALL which avoids the creation of a temporary tuple.
The signature of docstrings is also enhanced. For example,
get(...)
becomes:
get(self, key, default=None, /)
|
|\
| |
| |
| |
| | |
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
|
| |\
| | |
| | |
| | |
| | | |
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
|
| | |
| | |
| | |
| | |
| | | |
KeyError could be raised when cached function with full cache was
simultaneously called from differen threads with the same uncached arguments.
|
|\ \ \
| |/ /
| | |
| | | |
WeakValueDictionary when collecting from another thread.
|
| |\ \
| | |/
| | |
| | | |
WeakValueDictionary when collecting from another thread.
|
| | |
| | |
| | |
| | | |
WeakValueDictionary when collecting from another thread.
|
| | |
| | |
| | |
| | | |
setattr() must not convert combined table into split table.
|
| | |
| | |
| | |
| | | |
(Patch by Xiang Zhang)
|
|\ \ \
| |/ / |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Issue #28147: Fix a memory leak in split-table dictionaries: setattr() must not
convert combined table into split table.
Patch written by INADA Naoki.
|
| | |
| | |
| | |
| | | |
Improve speed of dict literal with constant keys up to 30%.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Replace:
PyObject_CallObject(callable, NULL)
with:
_PyObject_CallNoArg(callable)
|
| | |
| | |
| | |
| | |
| | |
| | | |
Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like
_PyObject_CallArg1() uses more stack memory than
PyObject_CallFunctionObjArgs().
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func)
* PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg)
PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires
extra work to "parse" C arguments to build a C array of PyObject*.
_PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate
memory on the C stack.
This change is part of the fastcall project. The change on listsort() is
related to the issue #23507.
|
| | |
| | |
| | |
| | | |
Improve speed of dict literal with constant keys up to 30%.
|
| | |
| | |
| | |
| | | |
It's common to see these functions in the top 3 of "perf report".
|
| | |
| | |
| | |
| | |
| | | |
It seems like _PyThreadState_UncheckedGet() is not inlined as expected, even
when using gcc -O3.
|
| | | |
|
|\ \ \
| |/ /
| | |
| | | |
PyDict_GetItemWithError(). Patch by Xiang Zhang.
|
| | |
| | |
| | |
| | | |
PyDict_GetItemWithError(). Patch by Xiang Zhang.
|
| | |
| | |
| | |
| | | |
Patch by Xiang Zhang.
|
|\ \ \
| |/ /
| | |
| | | |
Patch by Xiang Zhang.
|