dictobject.h 3.6 KB

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