Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
dictobject.h109 linesDownload Raw Back to include
1#ifndef Py_DICTOBJECT_H2#define Py_DICTOBJECT_H3#ifdef __cplusplus4extern "C" {5#endif6 7/* Dictionary object type -- mapping from hashable object to object */8 9/* The distribution includes a separate file, Objects/dictnotes.txt,10   describing explorations into dictionary design and optimization.11   It covers typical dictionary use patterns, the parameters for12   tuning dictionaries, and several ideas for possible optimizations.13*/14 15PyAPI_DATA(PyTypeObject) PyDict_Type;16 17#define PyDict_Check(op) \18                 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)19#define PyDict_CheckExact(op) Py_IS_TYPE((op), &PyDict_Type)20 21PyAPI_FUNC(PyObject *) PyDict_New(void);22PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);23PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key);24PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);25PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);26PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);27PyAPI_FUNC(int) PyDict_Next(28    PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);29PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);30PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);31PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);32PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);33PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);34PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);35 36/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */37PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);38 39/* PyDict_Merge updates/merges from a mapping object (an object that40   supports PyMapping_Keys() and PyObject_GetItem()).  If override is true,41   the last occurrence of a key wins, else the first.  The Python42   dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).43*/44PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,45                             PyObject *other,46                             int override);47 48/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing49   iterable objects of length 2.  If override is true, the last occurrence50   of a key wins, else the first.  The Python dict constructor dict(seq2)51   is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).52*/53PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,54                                     PyObject *seq2,55                                     int override);56 57PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);58PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);59PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);60 61#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D000062// Return the object from dictionary *op* which has a key *key*.63// - If the key is present, set *result to a new strong reference to the value64//   and return 1.65// - If the key is missing, set *result to NULL and return 0 .66// - On error, raise an exception and return -1.67PyAPI_FUNC(int) PyDict_GetItemRef(PyObject *mp, PyObject *key, PyObject **result);68PyAPI_FUNC(int) PyDict_GetItemStringRef(PyObject *mp, const char *key, PyObject **result);69#endif70 71#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A000072PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *);73#endif74 75/* Dictionary (keys, values, items) views */76 77PyAPI_DATA(PyTypeObject) PyDictKeys_Type;78PyAPI_DATA(PyTypeObject) PyDictValues_Type;79PyAPI_DATA(PyTypeObject) PyDictItems_Type;80 81#define PyDictKeys_Check(op) PyObject_TypeCheck((op), &PyDictKeys_Type)82#define PyDictValues_Check(op) PyObject_TypeCheck((op), &PyDictValues_Type)83#define PyDictItems_Check(op) PyObject_TypeCheck((op), &PyDictItems_Type)84/* This excludes Values, since they are not sets. */85# define PyDictViewSet_Check(op) \86    (PyDictKeys_Check(op) || PyDictItems_Check(op))87 88/* Dictionary (key, value, items) iterators */89 90PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;91PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;92PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;93 94PyAPI_DATA(PyTypeObject) PyDictRevIterKey_Type;95PyAPI_DATA(PyTypeObject) PyDictRevIterItem_Type;96PyAPI_DATA(PyTypeObject) PyDictRevIterValue_Type;97 98 99#ifndef Py_LIMITED_API100#  define Py_CPYTHON_DICTOBJECT_H101#  include "cpython/dictobject.h"102#  undef Py_CPYTHON_DICTOBJECT_H103#endif104 105#ifdef __cplusplus106}107#endif108#endif /* !Py_DICTOBJECT_H */109 
codekingpro/portable-devtools · Team Ai