+++ /dev/null
-#ifndef Py_DICTOBJECT_H\r
-#define Py_DICTOBJECT_H\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-\r
-/* Dictionary object type -- mapping from hashable object to object */\r
-\r
-/* The distribution includes a separate file, Objects/dictnotes.txt,\r
- describing explorations into dictionary design and optimization.\r
- It covers typical dictionary use patterns, the parameters for\r
- tuning dictionaries, and several ideas for possible optimizations.\r
-*/\r
-\r
-/*\r
-There are three kinds of slots in the table:\r
-\r
-1. Unused. me_key == me_value == NULL\r
- Does not hold an active (key, value) pair now and never did. Unused can\r
- transition to Active upon key insertion. This is the only case in which\r
- me_key is NULL, and is each slot's initial state.\r
-\r
-2. Active. me_key != NULL and me_key != dummy and me_value != NULL\r
- Holds an active (key, value) pair. Active can transition to Dummy upon\r
- key deletion. This is the only case in which me_value != NULL.\r
-\r
-3. Dummy. me_key == dummy and me_value == NULL\r
- Previously held an active (key, value) pair, but that was deleted and an\r
- active pair has not yet overwritten the slot. Dummy can transition to\r
- Active upon key insertion. Dummy slots cannot be made Unused again\r
- (cannot have me_key set to NULL), else the probe sequence in case of\r
- collision would have no way to know they were once active.\r
-\r
-Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to\r
-hold a search finger. The me_hash field of Unused or Dummy slots has no\r
-meaning otherwise.\r
-*/\r
-\r
-/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are\r
- * allocated directly in the dict object (in the ma_smalltable member).\r
- * It must be a power of 2, and at least 4. 8 allows dicts with no more\r
- * than 5 active entries to live in ma_smalltable (and so avoid an\r
- * additional malloc); instrumentation suggested this suffices for the\r
- * majority of dicts (consisting mostly of usually-small instance dicts and\r
- * usually-small dicts created to pass keyword arguments).\r
- */\r
-#define PyDict_MINSIZE 8\r
-\r
-typedef struct {\r
- /* Cached hash code of me_key. Note that hash codes are C longs.\r
- * We have to use Py_ssize_t instead because dict_popitem() abuses\r
- * me_hash to hold a search finger.\r
- */\r
- Py_ssize_t me_hash;\r
- PyObject *me_key;\r
- PyObject *me_value;\r
-} PyDictEntry;\r
-\r
-/*\r
-To ensure the lookup algorithm terminates, there must be at least one Unused\r
-slot (NULL key) in the table.\r
-The value ma_fill is the number of non-NULL keys (sum of Active and Dummy);\r
-ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL\r
-values == the number of Active items).\r
-To avoid slowing down lookups on a near-full table, we resize the table when\r
-it's two-thirds full.\r
-*/\r
-typedef struct _dictobject PyDictObject;\r
-struct _dictobject {\r
- PyObject_HEAD\r
- Py_ssize_t ma_fill; /* # Active + # Dummy */\r
- Py_ssize_t ma_used; /* # Active */\r
-\r
- /* The table contains ma_mask + 1 slots, and that's a power of 2.\r
- * We store the mask instead of the size because the mask is more\r
- * frequently needed.\r
- */\r
- Py_ssize_t ma_mask;\r
-\r
- /* ma_table points to ma_smalltable for small tables, else to\r
- * additional malloc'ed memory. ma_table is never NULL! This rule\r
- * saves repeated runtime null-tests in the workhorse getitem and\r
- * setitem calls.\r
- */\r
- PyDictEntry *ma_table;\r
- PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash);\r
- PyDictEntry ma_smalltable[PyDict_MINSIZE];\r
-};\r
-\r
-PyAPI_DATA(PyTypeObject) PyDict_Type;\r
-PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;\r
-PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;\r
-PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;\r
-PyAPI_DATA(PyTypeObject) PyDictKeys_Type;\r
-PyAPI_DATA(PyTypeObject) PyDictItems_Type;\r
-PyAPI_DATA(PyTypeObject) PyDictValues_Type;\r
-\r
-#define PyDict_Check(op) \\r
- PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)\r
-#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)\r
-#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type)\r
-#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type)\r
-#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type)\r
-/* This excludes Values, since they are not sets. */\r
-# define PyDictViewSet_Check(op) \\r
- (PyDictKeys_Check(op) || PyDictItems_Check(op))\r
-\r
-PyAPI_FUNC(PyObject *) PyDict_New(void);\r
-PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);\r
-PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);\r
-PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);\r
-PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);\r
-PyAPI_FUNC(int) PyDict_Next(\r
- PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);\r
-PyAPI_FUNC(int) _PyDict_Next(\r
- PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash);\r
-PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);\r
-PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);\r
-PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);\r
-PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);\r
-PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);\r
-PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);\r
-PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash);\r
-PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);\r
-PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);\r
-\r
-/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */\r
-PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);\r
-\r
-/* PyDict_Merge updates/merges from a mapping object (an object that\r
- supports PyMapping_Keys() and PyObject_GetItem()). If override is true,\r
- the last occurrence of a key wins, else the first. The Python\r
- dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).\r
-*/\r
-PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,\r
- PyObject *other,\r
- int override);\r
-\r
-/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing\r
- iterable objects of length 2. If override is true, the last occurrence\r
- of a key wins, else the first. The Python dict constructor dict(seq2)\r
- is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).\r
-*/\r
-PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,\r
- PyObject *seq2,\r
- int override);\r
-\r
-PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);\r
-PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);\r
-PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif /* !Py_DICTOBJECT_H */\r