Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/python2....
File: dictobject.h
#ifndef Py_DICTOBJECT_H
[0] Fix | Delete
#define Py_DICTOBJECT_H
[1] Fix | Delete
#ifdef __cplusplus
[2] Fix | Delete
extern "C" {
[3] Fix | Delete
#endif
[4] Fix | Delete
[5] Fix | Delete
[6] Fix | Delete
/* Dictionary object type -- mapping from hashable object to object */
[7] Fix | Delete
[8] Fix | Delete
/* The distribution includes a separate file, Objects/dictnotes.txt,
[9] Fix | Delete
describing explorations into dictionary design and optimization.
[10] Fix | Delete
It covers typical dictionary use patterns, the parameters for
[11] Fix | Delete
tuning dictionaries, and several ideas for possible optimizations.
[12] Fix | Delete
*/
[13] Fix | Delete
[14] Fix | Delete
/*
[15] Fix | Delete
There are three kinds of slots in the table:
[16] Fix | Delete
[17] Fix | Delete
1. Unused. me_key == me_value == NULL
[18] Fix | Delete
Does not hold an active (key, value) pair now and never did. Unused can
[19] Fix | Delete
transition to Active upon key insertion. This is the only case in which
[20] Fix | Delete
me_key is NULL, and is each slot's initial state.
[21] Fix | Delete
[22] Fix | Delete
2. Active. me_key != NULL and me_key != dummy and me_value != NULL
[23] Fix | Delete
Holds an active (key, value) pair. Active can transition to Dummy upon
[24] Fix | Delete
key deletion. This is the only case in which me_value != NULL.
[25] Fix | Delete
[26] Fix | Delete
3. Dummy. me_key == dummy and me_value == NULL
[27] Fix | Delete
Previously held an active (key, value) pair, but that was deleted and an
[28] Fix | Delete
active pair has not yet overwritten the slot. Dummy can transition to
[29] Fix | Delete
Active upon key insertion. Dummy slots cannot be made Unused again
[30] Fix | Delete
(cannot have me_key set to NULL), else the probe sequence in case of
[31] Fix | Delete
collision would have no way to know they were once active.
[32] Fix | Delete
[33] Fix | Delete
Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to
[34] Fix | Delete
hold a search finger. The me_hash field of Unused or Dummy slots has no
[35] Fix | Delete
meaning otherwise.
[36] Fix | Delete
*/
[37] Fix | Delete
[38] Fix | Delete
/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are
[39] Fix | Delete
* allocated directly in the dict object (in the ma_smalltable member).
[40] Fix | Delete
* It must be a power of 2, and at least 4. 8 allows dicts with no more
[41] Fix | Delete
* than 5 active entries to live in ma_smalltable (and so avoid an
[42] Fix | Delete
* additional malloc); instrumentation suggested this suffices for the
[43] Fix | Delete
* majority of dicts (consisting mostly of usually-small instance dicts and
[44] Fix | Delete
* usually-small dicts created to pass keyword arguments).
[45] Fix | Delete
*/
[46] Fix | Delete
#define PyDict_MINSIZE 8
[47] Fix | Delete
[48] Fix | Delete
typedef struct {
[49] Fix | Delete
/* Cached hash code of me_key. Note that hash codes are C longs.
[50] Fix | Delete
* We have to use Py_ssize_t instead because dict_popitem() abuses
[51] Fix | Delete
* me_hash to hold a search finger.
[52] Fix | Delete
*/
[53] Fix | Delete
Py_ssize_t me_hash;
[54] Fix | Delete
PyObject *me_key;
[55] Fix | Delete
PyObject *me_value;
[56] Fix | Delete
} PyDictEntry;
[57] Fix | Delete
[58] Fix | Delete
/*
[59] Fix | Delete
To ensure the lookup algorithm terminates, there must be at least one Unused
[60] Fix | Delete
slot (NULL key) in the table.
[61] Fix | Delete
The value ma_fill is the number of non-NULL keys (sum of Active and Dummy);
[62] Fix | Delete
ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL
[63] Fix | Delete
values == the number of Active items).
[64] Fix | Delete
To avoid slowing down lookups on a near-full table, we resize the table when
[65] Fix | Delete
it's two-thirds full.
[66] Fix | Delete
*/
[67] Fix | Delete
typedef struct _dictobject PyDictObject;
[68] Fix | Delete
struct _dictobject {
[69] Fix | Delete
PyObject_HEAD
[70] Fix | Delete
Py_ssize_t ma_fill; /* # Active + # Dummy */
[71] Fix | Delete
Py_ssize_t ma_used; /* # Active */
[72] Fix | Delete
[73] Fix | Delete
/* The table contains ma_mask + 1 slots, and that's a power of 2.
[74] Fix | Delete
* We store the mask instead of the size because the mask is more
[75] Fix | Delete
* frequently needed.
[76] Fix | Delete
*/
[77] Fix | Delete
Py_ssize_t ma_mask;
[78] Fix | Delete
[79] Fix | Delete
/* ma_table points to ma_smalltable for small tables, else to
[80] Fix | Delete
* additional malloc'ed memory. ma_table is never NULL! This rule
[81] Fix | Delete
* saves repeated runtime null-tests in the workhorse getitem and
[82] Fix | Delete
* setitem calls.
[83] Fix | Delete
*/
[84] Fix | Delete
PyDictEntry *ma_table;
[85] Fix | Delete
PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash);
[86] Fix | Delete
PyDictEntry ma_smalltable[PyDict_MINSIZE];
[87] Fix | Delete
};
[88] Fix | Delete
[89] Fix | Delete
PyAPI_DATA(PyTypeObject) PyDict_Type;
[90] Fix | Delete
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
[91] Fix | Delete
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
[92] Fix | Delete
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
[93] Fix | Delete
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
[94] Fix | Delete
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
[95] Fix | Delete
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
[96] Fix | Delete
[97] Fix | Delete
#define PyDict_Check(op) \
[98] Fix | Delete
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
[99] Fix | Delete
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
[100] Fix | Delete
#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type)
[101] Fix | Delete
#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type)
[102] Fix | Delete
#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type)
[103] Fix | Delete
/* This excludes Values, since they are not sets. */
[104] Fix | Delete
# define PyDictViewSet_Check(op) \
[105] Fix | Delete
(PyDictKeys_Check(op) || PyDictItems_Check(op))
[106] Fix | Delete
[107] Fix | Delete
PyAPI_FUNC(PyObject *) PyDict_New(void);
[108] Fix | Delete
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
[109] Fix | Delete
PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *mp, PyObject *key);
[110] Fix | Delete
PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
[111] Fix | Delete
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
[112] Fix | Delete
PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
[113] Fix | Delete
int (*predicate)(PyObject *value));
[114] Fix | Delete
[115] Fix | Delete
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
[116] Fix | Delete
PyAPI_FUNC(int) PyDict_Next(
[117] Fix | Delete
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
[118] Fix | Delete
PyAPI_FUNC(int) _PyDict_Next(
[119] Fix | Delete
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash);
[120] Fix | Delete
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
[121] Fix | Delete
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
[122] Fix | Delete
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
[123] Fix | Delete
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
[124] Fix | Delete
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
[125] Fix | Delete
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
[126] Fix | Delete
PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash);
[127] Fix | Delete
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
[128] Fix | Delete
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
[129] Fix | Delete
[130] Fix | Delete
/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
[131] Fix | Delete
PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
[132] Fix | Delete
[133] Fix | Delete
/* PyDict_Merge updates/merges from a mapping object (an object that
[134] Fix | Delete
supports PyMapping_Keys() and PyObject_GetItem()). If override is true,
[135] Fix | Delete
the last occurrence of a key wins, else the first. The Python
[136] Fix | Delete
dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
[137] Fix | Delete
*/
[138] Fix | Delete
PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
[139] Fix | Delete
PyObject *other,
[140] Fix | Delete
int override);
[141] Fix | Delete
[142] Fix | Delete
/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
[143] Fix | Delete
iterable objects of length 2. If override is true, the last occurrence
[144] Fix | Delete
of a key wins, else the first. The Python dict constructor dict(seq2)
[145] Fix | Delete
is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
[146] Fix | Delete
*/
[147] Fix | Delete
PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
[148] Fix | Delete
PyObject *seq2,
[149] Fix | Delete
int override);
[150] Fix | Delete
[151] Fix | Delete
PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
[152] Fix | Delete
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
[153] Fix | Delete
PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
[154] Fix | Delete
[155] Fix | Delete
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
[156] Fix | Delete
[157] Fix | Delete
#ifdef __cplusplus
[158] Fix | Delete
}
[159] Fix | Delete
#endif
[160] Fix | Delete
#endif /* !Py_DICTOBJECT_H */
[161] Fix | Delete
[162] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function