Sam Gross
de61d4bd4d
gh-112066: Add PyDict_SetDefaultRef
function. ( #112123 )
...
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>
2024-02-06 11:36:23 -05:00
Mark Shannon
0e71a295e9
GH-113710: Add a "globals to constants" pass (GH-114592)
...
Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
2024-02-02 12:14:34 +00:00
Donghee Na
13907968d7
gh-111968: Use per-thread freelists for dict in free-threading (gh-114323)
2024-02-01 20:53:53 +00:00
Dino Viehland
0990d55725
gh-112075: refactor dictionary lookup functions for better re-usability ( #114629 )
...
Refactor dict lookup functions to use force inline helpers
2024-01-30 09:33:36 -08:00
Dino Viehland
3d716655d2
gh-112075: Use PyMem_* for allocating dict keys objects ( #114543 )
...
Use PyMem_* for keys allocation
2024-01-29 09:38:03 -08:00
Dino Viehland
afe8f376c0
gh-112075: Adapt more dict methods to Argument Clinic ( #114256 )
...
* 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>
2024-01-23 22:10:04 +00:00
Christopher Chavez
a1eea1d032
gh-111178: Avoid calling functions from incompatible pointer types in dictobject.c ( #112892 )
...
Fix undefined behavior warnings (UBSan -fsanitize=function).
2024-01-02 15:32:37 +01:00
Victor Stinner
bd2f1485b0
gh-112026: Restore removed _PyDict_GetItemStringWithError() ( #112119 )
...
Restore the removed _PyDict_GetItemStringWithError() function. It is
used by numpy.
2023-11-15 17:10:06 +00:00
Victor Stinner
58469244be
gh-112026: Restore removed private C API ( #112115 )
...
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()
2023-11-15 16:38:31 +00:00
Victor Stinner
4f04172c92
gh-111262: Add PyDict_Pop() function ( #112028 )
...
_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>
2023-11-14 12:51:00 +00:00
Serhiy Storchaka
f55cb44359
gh-106672: C API: Report indiscriminately ignored errors (GH-106674)
...
Functions which indiscriminately ignore all errors now report them as
unraisable errors.
2023-11-07 15:58:04 +02:00
Serhiy Storchaka
970e719a7a
gh-108082: Use PyErr_FormatUnraisable() (GH-111580)
...
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>
2023-11-02 09:16:34 +00:00
Victor Stinner
fc2cb86d21
gh-107073: Make PyObject_VisitManagedDict() public ( #108763 )
...
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.
2023-10-02 19:24:08 +02:00
Serhiy Storchaka
add16f1a5e
gh-108511: Add C API functions which do not silently ignore errors (GH-109025)
...
Add the following functions:
* PyObject_HasAttrWithError()
* PyObject_HasAttrStringWithError()
* PyMapping_HasKeyWithError()
* PyMapping_HasKeyStringWithError()
2023-09-17 14:23:31 +03:00
Nikita Sobolev
47af188593
Add missing PyDoc_STR
calls ( #109393 )
...
In files:
* Modules/_ctypes/cfield.c
* Modules/_struct.c
* Objects/dictobject.c
* Objects/typevarobject.c
* Objects/unionobject.c
2023-09-15 15:10:48 +02:00
Victor Stinner
c494fb333b
gh-106320: Remove private _PyEval function ( #108433 )
...
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.
2023-08-24 20:25:22 +02:00
Victor Stinner
52c6a6e48a
gh-108308: Remove _PyDict_GetItemStringWithError() function ( #108426 )
...
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.
2023-08-24 17:34:22 +02:00
Victor Stinner
6726626646
gh-108314: Add PyDict_ContainsString() function ( #108323 )
2023-08-24 15:59:12 +02:00
Mark Shannon
666b68e8f2
GH-106485: Create object's dict-values instead of creating __dict__, when we can. (GH-107843)
2023-08-11 20:05:56 +01:00
Mark Shannon
1d976b2da2
GH-106485: Handle dict subclasses correctly when dematerializing __dict__
(GH-107837)
2023-08-10 13:34:00 +01:00
Brandt Bucher
326f0ba1c5
GH-106485: Dematerialize instance dictionaries when possible (GH-106539)
2023-08-09 19:14:50 +00:00
Victor Stinner
0d6dfd68d2
gh-106320: Remove private _PyObject C API ( #107147 )
...
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.
2023-07-23 20:09:08 +00:00
Victor Stinner
5e4af2a3e9
gh-106320: Move private _PySet API to the internal API ( #107041 )
...
* Add pycore_setobject.h header file.
* Move the following API to the internal C API:
* _PySet_Dummy
* _PySet_NextEntry()
* _PySet_Update()
2023-07-22 17:04:34 +02:00
Victor Stinner
41ca164551
gh-106004: Add PyDict_GetItemRef() function ( #106005 )
...
* 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.
2023-07-21 23:10:51 +02:00
Serhiy Storchaka
be1b968dc1
gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)
2023-07-12 08:57:10 +03:00
Mark Shannon
04492cbc9a
GH-91095: Specialize calls to normal Python classes. (GH-99331)
2023-06-22 09:48:19 +01:00
Dong-hee Na
b9fcfa6024
gh-104717: Add comment about manual loop unrolling (gh-104718)
2023-05-21 21:08:28 +09:00
Eric Snow
b8f7ab5783
gh-104252: Immortalize Py_EMPTY_KEYS (gh-104253)
...
This was missed in gh-19474. It matters for with a per-interpreter GIL since PyDictKeysObject.dk_refcnt breaks isolation and leads to races.
2023-05-10 07:28:40 -06:00
Eric Snow
743687434c
gh-102304: Move the Total Refcount to PyInterpreterState (gh-102545)
...
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
2023-03-21 11:46:09 -06:00
Inada Naoki
65fb7c4055
gh-102701: Fix overflow in dictobject.c (GH-102750)
2023-03-17 22:39:09 +09:00
Eric Snow
b45d14b886
gh-100227: Move dict_state.global_version to PyInterpreterState (gh-102338)
...
https://github.com/python/cpython/issues/100227
2023-03-09 08:16:30 -07:00
Eric Snow
5e5acd291f
gh-100227: Move next_keys_version to PyInterpreterState (gh-102335)
...
https://github.com/python/cpython/issues/100227
2023-03-08 18:04:16 -07:00
Eric Snow
cbb0aa71d0
gh-102304: Consolidate Direct Usage of _Py_RefTotal (gh-102514)
...
This simplifies further changes to _Py_RefTotal (e.g. make it atomic or move it to PyInterpreterState).
https://github.com/python/cpython/issues/102304
2023-03-08 12:03:50 -07:00
Irit Katriel
11a2c6ce51
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Objects/) ( #102218 )
2023-03-08 17:03:18 +00:00
Carl Meyer
1e703a4733
gh-102381: don't call watcher callback with dead object ( #102382 )
...
Co-authored-by: T. Wouters <thomas@python.org>
2023-03-07 17:10:58 -07:00
Mark Shannon
feec49c407
GH-101578: Normalize the current exception (GH-101607)
...
* 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
2023-02-08 09:31:12 +00:00
Victor Stinner
4246fe977d
gh-99845: Change _PyDict_KeysSize() return type to size_t ( #99848 )
...
* 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.
2022-11-29 12:12:17 +01:00
Eric Snow
9db1e17c80
gh-81057: Move the global Dict-Related Versions to _PyRuntimeState (gh-99497)
...
We also move the global func version.
https://github.com/python/cpython/issues/81057
2022-11-16 10:37:29 -07:00
Victor Stinner
8211cf5d28
gh-99300: Replace Py_INCREF() with Py_NewRef() ( #99530 )
...
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef()
and Py_XNewRef().
2022-11-16 18:34:24 +01:00
Victor Stinner
6dedf42527
gh-99300: Use Py_NewRef() in Objects/dictobject.c ( #99333 )
...
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in Objects/dictobject.c.
2022-11-10 16:27:53 +01:00
Carl Meyer
e82d977eb0
gh-91052: Add PyDict_Unwatch for unwatching a dictionary ( #98055 )
2022-10-07 17:37:46 -07:00
Carl Meyer
a4b7794887
GH-91052: Add C API for watching dictionaries (GH-31787)
2022-10-07 01:08:00 +01:00
Samuel
8563966be4
Fix minor comment typo in dictobject.c (GH-96960)
...
Fix a minor comment typo in the Objects/dictobject.c file.
Automerge-Triggered-By: GH:methane
2022-09-20 05:17:40 -07:00
Nikita Sobolev
30cc1901ef
gh-96364: Fix text signatures of __getitem__
for list
and dict
(GH-96365)
2022-09-09 17:37:02 +09:00
Matthias Görgens
4a6fa89465
Remove dead code in _PyDict_GetItemHint and rename to _PyDict_LookupIndex (GH-95948)
2022-08-18 10:19:21 +01:00
Mark Shannon
de388c0a7b
GH-95245: Store object values and dict pointers in single tagged pointer. (GH-95278)
2022-08-01 14:34:54 +01:00
Mark Shannon
27055d766a
GH-92678: Expose managed dict clear and visit functions ( #95246 )
2022-07-25 22:30:53 +01:00
Géry Ogam
a95138b2c5
bpo-43857: Improve the AttributeError message when deleting a missing attribute ( #25424 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-05-05 06:37:26 -07:00
Mark Shannon
836b17c9c3
Add more stats for freelist use and allocations. (GH-92211)
2022-05-03 16:40:24 -06:00
Victor Stinner
804f2529d8
gh-91320: Use _PyCFunction_CAST() ( #92251 )
...
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).
Change generated by the command:
sed -i -e \
's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \
$(find -name "*.c")
2022-05-03 21:42:14 +02:00