| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Biased reference counting maintains two refcount fields in each object:
`ob_ref_local` and `ob_ref_shared`. The true refcount is the sum of these two
fields. In some cases, when refcounting operations are split across threads,
the ob_ref_shared field can be negative (although the total refcount must be
at least zero). In this case, the thread that decremented the refcount
requests that the owning thread give up ownership and merge the refcount
fields.
|
|
|
|
|
|
|
|
|
| |
Starts adding thread safety to dict objects.
Use @critical_section for APIs which are exposed via argument clinic and don't directly correlate with a public C API which needs to acquire the lock
Use a _lock_held suffix for keeping changes to complicated functions simple and just wrapping them with a critical section
Acquire and release the lock in an existing function where it won't be overly disruptive to the existing logic
|
|
|
|
|
|
|
| |
The `PyDict_SetDefaultRef` function is similar to `PyDict_SetDefault`,
but returns a strong reference through the optional `**result` pointer
instead of a borrowed reference.
Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
|
|
| |
Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
|
| |
|
|
|
|
|
| |
(#114629)
Refactor dict lookup functions to use force inline helpers
|
|
|
| |
Use PyMem_* for keys allocation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Move more dict objects to argument clinic
* Improve doc strings
* More doc string improvements
* Update Objects/dictobject.c
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* Update Objects/dictobject.c
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* Update Objects/dictobject.c
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* Update Objects/dictobject.c
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* Update Objects/dictobject.c
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* Update Objects/dictobject.c
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* Update Objects/dictobject.c
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
---------
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
|
|
|
|
|
| |
dictobject.c (#112892)
Fix undefined behavior warnings (UBSan -fsanitize=function).
|
|
|
|
| |
Restore the removed _PyDict_GetItemStringWithError() function. It is
used by numpy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Restore removed private C API functions, macros and structures which
have no simple replacement for now:
* _PyDict_GetItem_KnownHash()
* _PyDict_NewPresized()
* _PyHASH_BITS
* _PyHASH_IMAG
* _PyHASH_INF
* _PyHASH_MODULUS
* _PyHASH_MULTIPLIER
* _PyLong_Copy()
* _PyLong_FromDigits()
* _PyLong_New()
* _PyLong_Sign()
* _PyObject_CallMethodId()
* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_EXTRA_INIT
* _PyObject_FastCallDict()
* _PyObject_GetAttrId()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyStack_AsDict()
* _PyThread_CurrentFrames()
* _PyUnicodeWriter structure
* _PyUnicodeWriter_Dealloc()
* _PyUnicodeWriter_Finish()
* _PyUnicodeWriter_Init()
* _PyUnicodeWriter_Prepare()
* _PyUnicodeWriter_PrepareKind()
* _PyUnicodeWriter_WriteASCIIString()
* _PyUnicodeWriter_WriteChar()
* _PyUnicodeWriter_WriteLatin1String()
* _PyUnicodeWriter_WriteStr()
* _PyUnicodeWriter_WriteSubstring()
* _PyUnicode_AsString()
* _PyUnicode_FromId()
* _PyVectorcall_Function()
* _Py_HashDouble()
* _Py_HashPointer()
* _Py_IDENTIFIER()
* _Py_c_abs()
* _Py_c_diff()
* _Py_c_neg()
* _Py_c_pow()
* _Py_c_prod()
* _Py_c_quot()
* _Py_c_sum()
* _Py_static_string()
* _Py_static_string_init()
|
|
|
|
|
|
|
| |
_PyDict_Pop_KnownHash(): remove the default value and the return type
becomes an int.
Co-authored-by: Stefan Behnel <stefan_ml@behnel.de>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
|
|
|
|
|
| |
Functions which indiscriminately ignore all errors now report them as
unraisable errors.
|
|
|
|
|
|
| |
Replace most of calls of _PyErr_WriteUnraisableMsg() and some
calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().
Co-authored-by: Victor Stinner <vstinner@python.org>
|
|
|
|
|
|
|
|
| |
Make PyObject_VisitManagedDict() and PyObject_ClearManagedDict()
functions public in Python 3.13 C API.
* Rename _PyObject_VisitManagedDict() to PyObject_VisitManagedDict().
* Rename _PyObject_ClearManagedDict() to PyObject_ClearManagedDict().
* Document these functions.
|
|
|
|
|
|
|
|
|
| |
Add the following functions:
* PyObject_HasAttrWithError()
* PyObject_HasAttrStringWithError()
* PyMapping_HasKeyWithError()
* PyMapping_HasKeyStringWithError()
|
|
|
|
|
|
|
|
|
| |
In files:
* Modules/_ctypes/cfield.c
* Modules/_struct.c
* Objects/dictobject.c
* Objects/typevarobject.c
* Objects/unionobject.c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move private _PyEval functions to the internal C API
(pycore_ceval.h):
* _PyEval_GetBuiltin()
* _PyEval_GetBuiltinId()
* _PyEval_GetSwitchInterval()
* _PyEval_MakePendingCalls()
* _PyEval_SetProfile()
* _PyEval_SetSwitchInterval()
* _PyEval_SetTrace()
No longer export most of these functions.
|
|
|
|
|
|
|
|
| |
Remove the internal _PyDict_GetItemStringWithError() function. It can
now be replaced with the new public PyDict_ContainsString() and
PyDict_GetItemStringRef() functions.
getargs.c now now uses a strong reference for current_arg.
find_keyword() returns a strong reference.
|
| |
|
|
|
|
| |
can. (GH-107843)
|
|
|
|
| |
(GH-107837)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move private debug _PyObject functions to the internal C API
(pycore_object.h):
* _PyDebugAllocatorStats()
* _PyObject_CheckConsistency()
* _PyObject_DebugTypeStats()
* _PyObject_IsFreed()
No longer export most of these functions, except of
_PyObject_IsFreed().
Move test functions using _PyObject_IsFreed() from _testcapi to
_testinternalcapi. check_pyobject_is_freed() test no longer catch
_testcapi.error: the tested function cannot raise _testcapi.error.
|
|
|
|
|
|
|
|
| |
* Add pycore_setobject.h header file.
* Move the following API to the internal C API:
* _PySet_Dummy
* _PySet_NextEntry()
* _PySet_Update()
|
|
|
|
|
| |
* Add PyDict_GetItemRef() and PyDict_GetItemStringRef() functions.
Add these functions to the stable ABI version 3.13.
* Add unit tests on the PyDict C API in test_capi.
|
| |
|
| |
|
| |
|
|
|
| |
This was missed in gh-19474. It matters for with a per-interpreter GIL since PyDictKeysObject.dk_refcnt breaks isolation and leads to races.
|
|
|
|
|
| |
Moving it valuable with a per-interpreter GIL. However, it is also useful without one, since it allows us to identify refleaks within a single interpreter or where references are escaping an interpreter. This becomes more important as we move the obmalloc state to PyInterpreterState.
https://github.com/python/cpython/issues/102304
|
| |
|
|
|
| |
https://github.com/python/cpython/issues/100227
|
|
|
| |
https://github.com/python/cpython/issues/100227
|
|
|
|
|
| |
This simplifies further changes to _Py_RefTotal (e.g. make it atomic or move it to PyInterpreterState).
https://github.com/python/cpython/issues/102304
|
|
|
|
| |
(in Objects/) (#102218)
|
|
|
| |
Co-authored-by: T. Wouters <thomas@python.org>
|
|
|
|
|
|
|
|
|
|
| |
* Make sure that the current exception is always normalized.
* Remove redundant type and traceback fields for the current exception.
* Add new API functions: PyErr_GetRaisedException, PyErr_SetRaisedException
* Add new API functions: PyException_GetArgs, PyException_SetArgs
|
|
|
|
|
|
|
|
| |
* Change _PyDict_KeysSize() and shared_keys_usable_size() return type
from signed (Py_ssize_t) to unsigned (size_t) type.
* new_values() argument type is now unsigned (size_t).
* init_inline_values() now uses size_t rather than int for the 'i'
iterator variable.
* type.__sizeof__() implementation now uses unsigned (size_t) type.
|
|
|
|
|
| |
We also move the global func version.
https://github.com/python/cpython/issues/81057
|
|
|
|
| |
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef()
and Py_XNewRef().
|
|
|
|
| |
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in Objects/dictobject.c.
|
| |
|
| |
|
|
|
|
|
| |
Fix a minor comment typo in the Objects/dictobject.c file.
Automerge-Triggered-By: GH:methane
|
| |
|
|
|
|
| |
(GH-95948)
|
|
|
|
| |
(GH-95278)
|