diff options
author | Victor Stinner <vstinner@python.org> | 2023-11-14 12:51:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 12:51:00 (GMT) |
commit | 4f04172c9287c507f1426e02ddfc432f1f3ade54 (patch) | |
tree | 800ac400c3776336e1f52b49a0f10b4dae9af8c1 /Include | |
parent | f44d6ff6e0c9eeb0bb246a3dd8f99d40b7050054 (diff) | |
download | cpython-4f04172c9287c507f1426e02ddfc432f1f3ade54.zip cpython-4f04172c9287c507f1426e02ddfc432f1f3ade54.tar.gz cpython-4f04172c9287c507f1426e02ddfc432f1f3ade54.tar.bz2 |
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>
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/dictobject.h | 2 | ||||
-rw-r--r-- | Include/internal/pycore_dict.h | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h index 64a4042..6475384 100644 --- a/Include/cpython/dictobject.h +++ b/Include/cpython/dictobject.h @@ -46,6 +46,8 @@ static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { PyAPI_FUNC(int) PyDict_ContainsString(PyObject *mp, const char *key); +PyAPI_FUNC(int) PyDict_Pop(PyObject *dict, PyObject *key, PyObject **result); +PyAPI_FUNC(int) PyDict_PopString(PyObject *dict, const char *key, PyObject **result); PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *dict, PyObject *key, PyObject *default_value); /* Dictionary watchers */ diff --git a/Include/internal/pycore_dict.h b/Include/internal/pycore_dict.h index d01ef55..89f30a4 100644 --- a/Include/internal/pycore_dict.h +++ b/Include/internal/pycore_dict.h @@ -116,7 +116,11 @@ extern PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *); extern int _PyDict_SetItem_Take2(PyDictObject *op, PyObject *key, PyObject *value); extern int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value); -extern PyObject *_PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObject *); +extern int _PyDict_Pop_KnownHash( + PyDictObject *dict, + PyObject *key, + Py_hash_t hash, + PyObject **result); #define DKIX_EMPTY (-1) #define DKIX_DUMMY (-2) /* Used internally */ |