dictobject.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 splitted:
  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. PyAPI_FUNC(int) PyDict_ClearFreeList(void);
  55. /* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0,
  56. the first occurrence of a key wins, if override is 1, the last occurrence
  57. of a key wins, if override is 2, a KeyError with conflicting key as
  58. argument is raised.
  59. */
  60. PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
  61. PyAPI_FUNC(PyObject *) _PyDict_GetItemId(PyObject *dp, struct _Py_Identifier *key);
  62. PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
  63. PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
  64. PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
  65. int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
  66. PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
  67. /* _PyDictView */
  68. typedef struct {
  69. PyObject_HEAD
  70. PyDictObject *dv_dict;
  71. } _PyDictViewObject;
  72. PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
  73. PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
  74. #ifdef __cplusplus
  75. }
  76. #endif