summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-16 14:18:57 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-16 14:18:57 (GMT)
commit5ab81d787f455ba28367b5b71606cea376283574 (patch)
treee78623a175940cb3d25d950812d0079021b178b7 /Include
parent1d59a0aacf1ddd000b6c6e231cf82ddf74afe3b4 (diff)
downloadcpython-5ab81d787f455ba28367b5b71606cea376283574.zip
cpython-5ab81d787f455ba28367b5b71606cea376283574.tar.gz
cpython-5ab81d787f455ba28367b5b71606cea376283574.tar.bz2
Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of dict.
Diffstat (limited to 'Include')
-rw-r--r--Include/dictobject.h2
-rw-r--r--Include/odictobject.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/Include/dictobject.h b/Include/dictobject.h
index 30f114e..885694b 100644
--- a/Include/dictobject.h
+++ b/Include/dictobject.h
@@ -106,6 +106,8 @@ PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
#ifndef Py_LIMITED_API
+/* Get the number of items of a dictionary. */
+#define PyDict_GET_SIZE(mp) (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash);
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
diff --git a/Include/odictobject.h b/Include/odictobject.h
index c1d9592..9410a0d 100644
--- a/Include/odictobject.h
+++ b/Include/odictobject.h
@@ -21,7 +21,7 @@ PyAPI_DATA(PyTypeObject) PyODictValues_Type;
#define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type)
#define PyODict_CheckExact(op) (Py_TYPE(op) == &PyODict_Type)
-#define PyODict_SIZE(op) ((PyDictObject *)op)->ma_used
+#define PyODict_SIZE(op) PyDict_GET_SIZE((op))
#define PyODict_HasKey(od, key) (PyMapping_HasKey(PyObject *)od, key)
PyAPI_FUNC(PyObject *) PyODict_New(void);