/src/cpython/Include/cpython/dictobject.h
Line | Count | Source |
1 | | #ifndef Py_CPYTHON_DICTOBJECT_H |
2 | | # error "this header file must not be included directly" |
3 | | #endif |
4 | | |
5 | | typedef struct _dictkeysobject PyDictKeysObject; |
6 | | typedef struct _dictvalues PyDictValues; |
7 | | |
8 | | /* The ma_values pointer is NULL for a combined table |
9 | | * or points to an array of PyObject* for a split table |
10 | | */ |
11 | | typedef struct { |
12 | | PyObject_HEAD |
13 | | |
14 | | /* Number of items in the dictionary */ |
15 | | Py_ssize_t ma_used; |
16 | | |
17 | | /* This is a private field for CPython's internal use. |
18 | | * Bits 0-7 are for dict watchers. |
19 | | * Bits 8-11 are for the watched mutation counter (used by tier2 optimization) |
20 | | * Bits 12-31 are currently unused |
21 | | * Bits 32-63 are a unique id in the free threading build (used for per-thread refcounting) |
22 | | */ |
23 | | uint64_t _ma_watcher_tag; |
24 | | |
25 | | PyDictKeysObject *ma_keys; |
26 | | |
27 | | /* If ma_values is NULL, the table is "combined": keys and values |
28 | | are stored in ma_keys. |
29 | | |
30 | | If ma_values is not NULL, the table is split: |
31 | | keys are stored in ma_keys and values are stored in ma_values */ |
32 | | PyDictValues *ma_values; |
33 | | } PyDictObject; |
34 | | |
35 | | PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key, |
36 | | Py_hash_t hash); |
37 | | // PyDict_GetItemStringRef() can be used instead |
38 | | Py_DEPRECATED(3.14) PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *); |
39 | | PyAPI_FUNC(PyObject *) PyDict_SetDefault( |
40 | | PyObject *mp, PyObject *key, PyObject *defaultobj); |
41 | | |
42 | | // Inserts `key` with a value `default_value`, if `key` is not already present |
43 | | // in the dictionary. If `result` is not NULL, then the value associated |
44 | | // with `key` is returned in `*result` (either the existing value, or the now |
45 | | // inserted `default_value`). |
46 | | // Returns: |
47 | | // -1 on error |
48 | | // 0 if `key` was not present and `default_value` was inserted |
49 | | // 1 if `key` was present and `default_value` was not inserted |
50 | | PyAPI_FUNC(int) PyDict_SetDefaultRef(PyObject *mp, PyObject *key, PyObject *default_value, PyObject **result); |
51 | | |
52 | | /* Get the number of items of a dictionary. */ |
53 | 38.0M | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { |
54 | 38.0M | PyDictObject *mp; |
55 | 38.0M | assert(PyDict_Check(op)); |
56 | 38.0M | mp = _Py_CAST(PyDictObject*, op); |
57 | | #ifdef Py_GIL_DISABLED |
58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); |
59 | | #else |
60 | 38.0M | return mp->ma_used; |
61 | 38.0M | #endif |
62 | 38.0M | } Unexecuted instantiation: bytesobject.c:PyDict_GET_SIZE Line | Count | Source | 53 | 19.8M | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 19.8M | PyDictObject *mp; | 55 | 19.8M | assert(PyDict_Check(op)); | 56 | 19.8M | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 19.8M | return mp->ma_used; | 61 | 19.8M | #endif | 62 | 19.8M | } |
Unexecuted instantiation: exceptions.c:PyDict_GET_SIZE Unexecuted instantiation: genericaliasobject.c:PyDict_GET_SIZE Unexecuted instantiation: floatobject.c:PyDict_GET_SIZE listobject.c:PyDict_GET_SIZE Line | Count | Source | 53 | 311 | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 311 | PyDictObject *mp; | 55 | 311 | assert(PyDict_Check(op)); | 56 | 311 | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 311 | return mp->ma_used; | 61 | 311 | #endif | 62 | 311 | } |
Unexecuted instantiation: longobject.c:PyDict_GET_SIZE Unexecuted instantiation: dictobject.c:PyDict_GET_SIZE Unexecuted instantiation: memoryobject.c:PyDict_GET_SIZE Unexecuted instantiation: moduleobject.c:PyDict_GET_SIZE Unexecuted instantiation: object.c:PyDict_GET_SIZE Unexecuted instantiation: obmalloc.c:PyDict_GET_SIZE Unexecuted instantiation: picklebufobject.c:PyDict_GET_SIZE Unexecuted instantiation: rangeobject.c:PyDict_GET_SIZE setobject.c:PyDict_GET_SIZE Line | Count | Source | 53 | 94 | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 94 | PyDictObject *mp; | 55 | 94 | assert(PyDict_Check(op)); | 56 | 94 | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 94 | return mp->ma_used; | 61 | 94 | #endif | 62 | 94 | } |
Unexecuted instantiation: sliceobject.c:PyDict_GET_SIZE Unexecuted instantiation: structseq.c:PyDict_GET_SIZE Unexecuted instantiation: templateobject.c:PyDict_GET_SIZE Unexecuted instantiation: tupleobject.c:PyDict_GET_SIZE typeobject.c:PyDict_GET_SIZE Line | Count | Source | 53 | 5.78M | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 5.78M | PyDictObject *mp; | 55 | 5.78M | assert(PyDict_Check(op)); | 56 | 5.78M | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 5.78M | return mp->ma_used; | 61 | 5.78M | #endif | 62 | 5.78M | } |
Unexecuted instantiation: typevarobject.c:PyDict_GET_SIZE Unexecuted instantiation: unicode_format.c:PyDict_GET_SIZE Unexecuted instantiation: unicode_formatter.c:PyDict_GET_SIZE Unexecuted instantiation: unicodectype.c:PyDict_GET_SIZE Unexecuted instantiation: unicodeobject.c:PyDict_GET_SIZE Unexecuted instantiation: unionobject.c:PyDict_GET_SIZE Unexecuted instantiation: weakrefobject.c:PyDict_GET_SIZE Unexecuted instantiation: _warnings.c:PyDict_GET_SIZE Unexecuted instantiation: bltinmodule.c:PyDict_GET_SIZE Line | Count | Source | 53 | 82.4k | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 82.4k | PyDictObject *mp; | 55 | 82.4k | assert(PyDict_Check(op)); | 56 | 82.4k | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 82.4k | return mp->ma_used; | 61 | 82.4k | #endif | 62 | 82.4k | } |
Unexecuted instantiation: codecs.c:PyDict_GET_SIZE Unexecuted instantiation: codegen.c:PyDict_GET_SIZE compile.c:PyDict_GET_SIZE Line | Count | Source | 53 | 125k | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 125k | PyDictObject *mp; | 55 | 125k | assert(PyDict_Check(op)); | 56 | 125k | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 125k | return mp->ma_used; | 61 | 125k | #endif | 62 | 125k | } |
Unexecuted instantiation: context.c:PyDict_GET_SIZE Unexecuted instantiation: errors.c:PyDict_GET_SIZE flowgraph.c:PyDict_GET_SIZE Line | Count | Source | 53 | 69.9k | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 69.9k | PyDictObject *mp; | 55 | 69.9k | assert(PyDict_Check(op)); | 56 | 69.9k | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 69.9k | return mp->ma_used; | 61 | 69.9k | #endif | 62 | 69.9k | } |
Unexecuted instantiation: frame.c:PyDict_GET_SIZE Unexecuted instantiation: future.c:PyDict_GET_SIZE Unexecuted instantiation: gc.c:PyDict_GET_SIZE Unexecuted instantiation: gc_gil.c:PyDict_GET_SIZE getargs.c:PyDict_GET_SIZE Line | Count | Source | 53 | 12.0M | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 12.0M | PyDictObject *mp; | 55 | 12.0M | assert(PyDict_Check(op)); | 56 | 12.0M | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 12.0M | return mp->ma_used; | 61 | 12.0M | #endif | 62 | 12.0M | } |
Unexecuted instantiation: ceval_gil.c:PyDict_GET_SIZE Unexecuted instantiation: hamt.c:PyDict_GET_SIZE Unexecuted instantiation: hashtable.c:PyDict_GET_SIZE Unexecuted instantiation: import.c:PyDict_GET_SIZE Unexecuted instantiation: importdl.c:PyDict_GET_SIZE Unexecuted instantiation: initconfig.c:PyDict_GET_SIZE Unexecuted instantiation: instrumentation.c:PyDict_GET_SIZE Unexecuted instantiation: instruction_sequence.c:PyDict_GET_SIZE Unexecuted instantiation: intrinsics.c:PyDict_GET_SIZE Unexecuted instantiation: legacy_tracing.c:PyDict_GET_SIZE Unexecuted instantiation: lock.c:PyDict_GET_SIZE Unexecuted instantiation: marshal.c:PyDict_GET_SIZE Unexecuted instantiation: modsupport.c:PyDict_GET_SIZE Unexecuted instantiation: mysnprintf.c:PyDict_GET_SIZE Unexecuted instantiation: parking_lot.c:PyDict_GET_SIZE Unexecuted instantiation: preconfig.c:PyDict_GET_SIZE Unexecuted instantiation: pyarena.c:PyDict_GET_SIZE Unexecuted instantiation: pyctype.c:PyDict_GET_SIZE Unexecuted instantiation: pyhash.c:PyDict_GET_SIZE Unexecuted instantiation: pylifecycle.c:PyDict_GET_SIZE Unexecuted instantiation: pymath.c:PyDict_GET_SIZE Unexecuted instantiation: pystate.c:PyDict_GET_SIZE Unexecuted instantiation: pythonrun.c:PyDict_GET_SIZE Unexecuted instantiation: pytime.c:PyDict_GET_SIZE Unexecuted instantiation: qsbr.c:PyDict_GET_SIZE Unexecuted instantiation: bootstrap_hash.c:PyDict_GET_SIZE Unexecuted instantiation: specialize.c:PyDict_GET_SIZE Unexecuted instantiation: symtable.c:PyDict_GET_SIZE Unexecuted instantiation: sysmodule.c:PyDict_GET_SIZE Unexecuted instantiation: thread.c:PyDict_GET_SIZE Unexecuted instantiation: traceback.c:PyDict_GET_SIZE Unexecuted instantiation: tracemalloc.c:PyDict_GET_SIZE Unexecuted instantiation: getopt.c:PyDict_GET_SIZE Unexecuted instantiation: pystrcmp.c:PyDict_GET_SIZE Unexecuted instantiation: pystrtod.c:PyDict_GET_SIZE Unexecuted instantiation: pystrhex.c:PyDict_GET_SIZE Unexecuted instantiation: dtoa.c:PyDict_GET_SIZE Unexecuted instantiation: fileutils.c:PyDict_GET_SIZE Unexecuted instantiation: suggestions.c:PyDict_GET_SIZE Unexecuted instantiation: perf_trampoline.c:PyDict_GET_SIZE Unexecuted instantiation: perf_jit_trampoline.c:PyDict_GET_SIZE Unexecuted instantiation: remote_debugging.c:PyDict_GET_SIZE Unexecuted instantiation: dynload_shlib.c:PyDict_GET_SIZE Unexecuted instantiation: config.c:PyDict_GET_SIZE Unexecuted instantiation: gcmodule.c:PyDict_GET_SIZE Unexecuted instantiation: _asynciomodule.c:PyDict_GET_SIZE Unexecuted instantiation: atexitmodule.c:PyDict_GET_SIZE Unexecuted instantiation: faulthandler.c:PyDict_GET_SIZE Unexecuted instantiation: posixmodule.c:PyDict_GET_SIZE Unexecuted instantiation: signalmodule.c:PyDict_GET_SIZE Unexecuted instantiation: _tracemalloc.c:PyDict_GET_SIZE Unexecuted instantiation: _suggestions.c:PyDict_GET_SIZE Unexecuted instantiation: _datetimemodule.c:PyDict_GET_SIZE Unexecuted instantiation: _codecsmodule.c:PyDict_GET_SIZE Unexecuted instantiation: _collectionsmodule.c:PyDict_GET_SIZE Unexecuted instantiation: _iomodule.c:PyDict_GET_SIZE Unexecuted instantiation: iobase.c:PyDict_GET_SIZE Unexecuted instantiation: fileio.c:PyDict_GET_SIZE Unexecuted instantiation: bytesio.c:PyDict_GET_SIZE Unexecuted instantiation: bufferedio.c:PyDict_GET_SIZE Unexecuted instantiation: textio.c:PyDict_GET_SIZE stringio.c:PyDict_GET_SIZE Line | Count | Source | 53 | 16.3k | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 16.3k | PyDictObject *mp; | 55 | 16.3k | assert(PyDict_Check(op)); | 56 | 16.3k | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 16.3k | return mp->ma_used; | 61 | 16.3k | #endif | 62 | 16.3k | } |
Unexecuted instantiation: itertoolsmodule.c:PyDict_GET_SIZE Line | Count | Source | 53 | 222 | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 222 | PyDictObject *mp; | 55 | 222 | assert(PyDict_Check(op)); | 56 | 222 | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 222 | return mp->ma_used; | 61 | 222 | #endif | 62 | 222 | } |
Unexecuted instantiation: _sysconfig.c:PyDict_GET_SIZE Unexecuted instantiation: _threadmodule.c:PyDict_GET_SIZE Unexecuted instantiation: timemodule.c:PyDict_GET_SIZE Unexecuted instantiation: _typesmodule.c:PyDict_GET_SIZE Unexecuted instantiation: _typingmodule.c:PyDict_GET_SIZE Unexecuted instantiation: _weakref.c:PyDict_GET_SIZE Unexecuted instantiation: _abc.c:PyDict_GET_SIZE _functoolsmodule.c:PyDict_GET_SIZE Line | Count | Source | 53 | 37.8k | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 37.8k | PyDictObject *mp; | 55 | 37.8k | assert(PyDict_Check(op)); | 56 | 37.8k | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 37.8k | return mp->ma_used; | 61 | 37.8k | #endif | 62 | 37.8k | } |
Unexecuted instantiation: _localemodule.c:PyDict_GET_SIZE Unexecuted instantiation: _opcode.c:PyDict_GET_SIZE Unexecuted instantiation: _operator.c:PyDict_GET_SIZE Unexecuted instantiation: symtablemodule.c:PyDict_GET_SIZE Unexecuted instantiation: pwdmodule.c:PyDict_GET_SIZE Unexecuted instantiation: getpath.c:PyDict_GET_SIZE Unexecuted instantiation: frozen.c:PyDict_GET_SIZE Unexecuted instantiation: getbuildinfo.c:PyDict_GET_SIZE Unexecuted instantiation: peg_api.c:PyDict_GET_SIZE Unexecuted instantiation: file_tokenizer.c:PyDict_GET_SIZE Unexecuted instantiation: helpers.c:PyDict_GET_SIZE Unexecuted instantiation: myreadline.c:PyDict_GET_SIZE Unexecuted instantiation: abstract.c:PyDict_GET_SIZE Unexecuted instantiation: boolobject.c:PyDict_GET_SIZE Unexecuted instantiation: bytes_methods.c:PyDict_GET_SIZE Unexecuted instantiation: bytearrayobject.c:PyDict_GET_SIZE Unexecuted instantiation: capsule.c:PyDict_GET_SIZE Unexecuted instantiation: cellobject.c:PyDict_GET_SIZE Unexecuted instantiation: classobject.c:PyDict_GET_SIZE Unexecuted instantiation: codeobject.c:PyDict_GET_SIZE Unexecuted instantiation: complexobject.c:PyDict_GET_SIZE Unexecuted instantiation: descrobject.c:PyDict_GET_SIZE Unexecuted instantiation: enumobject.c:PyDict_GET_SIZE Unexecuted instantiation: genobject.c:PyDict_GET_SIZE Unexecuted instantiation: fileobject.c:PyDict_GET_SIZE Unexecuted instantiation: frameobject.c:PyDict_GET_SIZE Unexecuted instantiation: funcobject.c:PyDict_GET_SIZE Unexecuted instantiation: interpolationobject.c:PyDict_GET_SIZE Unexecuted instantiation: iterobject.c:PyDict_GET_SIZE odictobject.c:PyDict_GET_SIZE Line | Count | Source | 53 | 172 | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 172 | PyDictObject *mp; | 55 | 172 | assert(PyDict_Check(op)); | 56 | 172 | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 172 | return mp->ma_used; | 61 | 172 | #endif | 62 | 172 | } |
Unexecuted instantiation: methodobject.c:PyDict_GET_SIZE Unexecuted instantiation: namespaceobject.c:PyDict_GET_SIZE Unexecuted instantiation: _contextvars.c:PyDict_GET_SIZE Unexecuted instantiation: Python-ast.c:PyDict_GET_SIZE Unexecuted instantiation: Python-tokenize.c:PyDict_GET_SIZE Unexecuted instantiation: asdl.c:PyDict_GET_SIZE assemble.c:PyDict_GET_SIZE Line | Count | Source | 53 | 13.8k | static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) { | 54 | 13.8k | PyDictObject *mp; | 55 | 13.8k | assert(PyDict_Check(op)); | 56 | 13.8k | mp = _Py_CAST(PyDictObject*, op); | 57 | | #ifdef Py_GIL_DISABLED | 58 | | return _Py_atomic_load_ssize_relaxed(&mp->ma_used); | 59 | | #else | 60 | 13.8k | return mp->ma_used; | 61 | 13.8k | #endif | 62 | 13.8k | } |
Unexecuted instantiation: ast.c:PyDict_GET_SIZE Unexecuted instantiation: ast_preprocess.c:PyDict_GET_SIZE Unexecuted instantiation: ast_unparse.c:PyDict_GET_SIZE Unexecuted instantiation: critical_section.c:PyDict_GET_SIZE Unexecuted instantiation: crossinterp.c:PyDict_GET_SIZE Unexecuted instantiation: getcopyright.c:PyDict_GET_SIZE Unexecuted instantiation: getplatform.c:PyDict_GET_SIZE Unexecuted instantiation: getversion.c:PyDict_GET_SIZE Unexecuted instantiation: optimizer.c:PyDict_GET_SIZE Unexecuted instantiation: pathconfig.c:PyDict_GET_SIZE Unexecuted instantiation: structmember.c:PyDict_GET_SIZE Unexecuted instantiation: pegen.c:PyDict_GET_SIZE Unexecuted instantiation: pegen_errors.c:PyDict_GET_SIZE Unexecuted instantiation: parser.c:PyDict_GET_SIZE Unexecuted instantiation: buffer.c:PyDict_GET_SIZE Unexecuted instantiation: lexer.c:PyDict_GET_SIZE Unexecuted instantiation: state.c:PyDict_GET_SIZE Unexecuted instantiation: readline_tokenizer.c:PyDict_GET_SIZE Unexecuted instantiation: string_tokenizer.c:PyDict_GET_SIZE Unexecuted instantiation: utf8_tokenizer.c:PyDict_GET_SIZE Unexecuted instantiation: getcompiler.c:PyDict_GET_SIZE Unexecuted instantiation: mystrtoul.c:PyDict_GET_SIZE Unexecuted instantiation: token.c:PyDict_GET_SIZE Unexecuted instantiation: action_helpers.c:PyDict_GET_SIZE Unexecuted instantiation: string_parser.c:PyDict_GET_SIZE |
63 | 38.1M | #define PyDict_GET_SIZE(op) PyDict_GET_SIZE(_PyObject_CAST(op)) |
64 | | |
65 | | PyAPI_FUNC(int) PyDict_ContainsString(PyObject *mp, const char *key); |
66 | | |
67 | | PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); |
68 | | |
69 | | PyAPI_FUNC(int) PyDict_Pop(PyObject *dict, PyObject *key, PyObject **result); |
70 | | PyAPI_FUNC(int) PyDict_PopString(PyObject *dict, const char *key, PyObject **result); |
71 | | |
72 | | // Use PyDict_Pop() instead |
73 | | Py_DEPRECATED(3.14) PyAPI_FUNC(PyObject *) _PyDict_Pop( |
74 | | PyObject *dict, |
75 | | PyObject *key, |
76 | | PyObject *default_value); |
77 | | |
78 | | /* Dictionary watchers */ |
79 | | |
80 | | #define PY_FOREACH_DICT_EVENT(V) \ |
81 | 0 | V(ADDED) \ |
82 | 0 | V(MODIFIED) \ |
83 | 0 | V(DELETED) \ |
84 | 0 | V(CLONED) \ |
85 | 0 | V(CLEARED) \ |
86 | 0 | V(DEALLOCATED) |
87 | | |
88 | | typedef enum { |
89 | | #define PY_DEF_EVENT(EVENT) PyDict_EVENT_##EVENT, |
90 | | PY_FOREACH_DICT_EVENT(PY_DEF_EVENT) |
91 | | #undef PY_DEF_EVENT |
92 | | } PyDict_WatchEvent; |
93 | | |
94 | | // Callback to be invoked when a watched dict is cleared, dealloced, or modified. |
95 | | // In clear/dealloc case, key and new_value will be NULL. Otherwise, new_value will be the |
96 | | // new value for key, NULL if key is being deleted. |
97 | | typedef int(*PyDict_WatchCallback)(PyDict_WatchEvent event, PyObject* dict, PyObject* key, PyObject* new_value); |
98 | | |
99 | | // Register/unregister a dict-watcher callback |
100 | | PyAPI_FUNC(int) PyDict_AddWatcher(PyDict_WatchCallback callback); |
101 | | PyAPI_FUNC(int) PyDict_ClearWatcher(int watcher_id); |
102 | | |
103 | | // Mark given dictionary as "watched" (callback will be called if it is modified) |
104 | | PyAPI_FUNC(int) PyDict_Watch(int watcher_id, PyObject* dict); |
105 | | PyAPI_FUNC(int) PyDict_Unwatch(int watcher_id, PyObject* dict); |