dictobject.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef Py_CPYTHON_DICTOBJECT_H
  2. # error "this header file must not be included directly"
  3. #endif
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct _dictkeysobject PyDictKeysObject;
  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. /* Number of items in the dictionary */
  14. Py_ssize_t ma_used;
  15. /* Dictionary version: globally unique, value change each time
  16. the dictionary is modified */
  17. uint64_t ma_version_tag;
  18. PyDictKeysObject *ma_keys;
  19. /* If ma_values is NULL, the table is "combined": keys and values
  20. are stored in ma_keys.
  21. If ma_values is not NULL, the table is split:
  22. keys are stored in ma_keys and values are stored in ma_values */
  23. PyObject **ma_values;
  24. } PyDictObject;
  25. PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
  26. Py_hash_t hash);
  27. PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
  28. struct _Py_Identifier *key);
  29. PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
  30. PyAPI_FUNC(PyObject *) PyDict_SetDefault(
  31. PyObject *mp, PyObject *key, PyObject *defaultobj);
  32. PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
  33. PyObject *item, Py_hash_t hash);
  34. PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
  35. Py_hash_t hash);
  36. PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
  37. int (*predicate)(PyObject *value));
  38. PyDictKeysObject *_PyDict_NewKeysForClass(void);
  39. PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *);
  40. PyAPI_FUNC(int) _PyDict_Next(
  41. PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
  42. /* Get the number of items of a dictionary. */
  43. #define PyDict_GET_SIZE(mp) (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
  44. PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash);
  45. PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
  46. PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
  47. PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
  48. Py_ssize_t _PyDict_KeysSize(PyDictKeysObject *keys);
  49. PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
  50. PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
  51. PyObject *_PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObject *);
  52. PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
  53. #define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL)
  54. /* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0,
  55. the first occurrence of a key wins, if override is 1, the last occurrence
  56. of a key wins, if override is 2, a KeyError with conflicting key as
  57. argument is raised.
  58. */
  59. PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
  60. PyAPI_FUNC(PyObject *) _PyDict_GetItemId(PyObject *dp, struct _Py_Identifier *key);
  61. PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
  62. PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
  63. PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
  64. int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
  65. PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
  66. /* _PyDictView */
  67. typedef struct {
  68. PyObject_HEAD
  69. PyDictObject *dv_dict;
  70. } _PyDictViewObject;
  71. PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
  72. PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
  73. #ifdef __cplusplus
  74. }
  75. #endif