| #ifndef Py_CPYTHON_DICTOBJECT_H |
| # error "this header file must not be included directly" |
| #endif |
|
|
| typedef struct _dictkeysobject PyDictKeysObject; |
| typedef struct _dictvalues PyDictValues; |
|
|
| |
| |
| |
| typedef struct { |
| PyObject_HEAD |
|
|
| |
| Py_ssize_t ma_used; |
|
|
| |
| |
| #ifdef Py_BUILD_CORE |
| |
| |
| |
| uint64_t ma_version_tag; |
| #else |
| Py_DEPRECATED(3.12) uint64_t ma_version_tag; |
| #endif |
|
|
| PyDictKeysObject *ma_keys; |
|
|
| |
| |
| |
| |
| |
| PyDictValues *ma_values; |
| } PyDictObject; |
|
|
| PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key, |
| Py_hash_t hash); |
| PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *); |
| PyAPI_FUNC(PyObject *) PyDict_SetDefault( |
| PyObject *mp, PyObject *key, PyObject *defaultobj); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| PyAPI_FUNC(int) PyDict_SetDefaultRef(PyObject *mp, PyObject *key, PyObject *default_value, PyObject **result); |
|
|
| |
| static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { |
| PyDictObject *mp; |
| assert(PyDict_Check(op)); |
| mp = _Py_CAST(PyDictObject*, op); |
| #ifdef Py_GIL_DISABLED |
| return _Py_atomic_load_ssize_relaxed(&mp->ma_used); |
| #else |
| return mp->ma_used; |
| #endif |
| } |
| #define PyDict_GET_SIZE(op) PyDict_GET_SIZE(_PyObject_CAST(op)) |
|
|
| PyAPI_FUNC(int) PyDict_ContainsString(PyObject *mp, const char *key); |
|
|
| PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); |
|
|
| 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); |
|
|
| |
|
|
| #define PY_FOREACH_DICT_EVENT(V) \ |
| V(ADDED) \ |
| V(MODIFIED) \ |
| V(DELETED) \ |
| V(CLONED) \ |
| V(CLEARED) \ |
| V(DEALLOCATED) |
|
|
| typedef enum { |
| #define PY_DEF_EVENT(EVENT) PyDict_EVENT_##EVENT, |
| PY_FOREACH_DICT_EVENT(PY_DEF_EVENT) |
| #undef PY_DEF_EVENT |
| } PyDict_WatchEvent; |
|
|
| |
| |
| |
| typedef int(*PyDict_WatchCallback)(PyDict_WatchEvent event, PyObject* dict, PyObject* key, PyObject* new_value); |
|
|
| |
| PyAPI_FUNC(int) PyDict_AddWatcher(PyDict_WatchCallback callback); |
| PyAPI_FUNC(int) PyDict_ClearWatcher(int watcher_id); |
|
|
| |
| PyAPI_FUNC(int) PyDict_Watch(int watcher_id, PyObject* dict); |
| PyAPI_FUNC(int) PyDict_Unwatch(int watcher_id, PyObject* dict); |
|
|