-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-141510: Update PyDict C API doc for frozendict #145533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
847567f
0119335
9a4a6d9
48d3591
60b622f
31a4385
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -42,6 +42,12 @@ Dictionary objects | |||||
| enforces read-only behavior. This is normally used to create a view to | ||||||
| prevent modification of the dictionary for non-dynamic class types. | ||||||
|
|
||||||
| The first argument can be a :class:`dict`, a :class:`frozendict`, or a | ||||||
| mapping. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
ZeroIntensity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
|
Comment on lines
+48
to
+50
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, do we need
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's nice to have an explicit historical record.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to be explicit about the change. |
||||||
|
|
||||||
| .. c:var:: PyTypeObject PyDictProxy_Type | ||||||
|
|
||||||
|
|
@@ -68,15 +74,25 @@ Dictionary objects | |||||
| *key*, return ``1``, otherwise return ``0``. On error, return ``-1``. | ||||||
| This is equivalent to the Python expression ``key in p``. | ||||||
|
|
||||||
| The first argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Also accept :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: int PyDict_ContainsString(PyObject *p, const char *key) | ||||||
|
|
||||||
| This is the same as :c:func:`PyDict_Contains`, but *key* is specified as a | ||||||
| :c:expr:`const char*` UTF-8 encoded bytes string, rather than a | ||||||
| :c:expr:`PyObject*`. | ||||||
|
|
||||||
| The first argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| .. versionadded:: 3.13 | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: PyObject* PyDict_Copy(PyObject *p) | ||||||
|
|
||||||
|
|
@@ -122,8 +138,13 @@ Dictionary objects | |||||
| * If the key is missing, set *\*result* to ``NULL`` and return ``0``. | ||||||
| * On error, raise an exception and return ``-1``. | ||||||
|
|
||||||
| The first argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| .. versionadded:: 3.13 | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
| See also the :c:func:`PyObject_GetItem` function. | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -133,6 +154,8 @@ Dictionary objects | |||||
| has a key *key*. Return ``NULL`` if the key *key* is missing *without* | ||||||
| setting an exception. | ||||||
|
|
||||||
| The first argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| .. note:: | ||||||
|
|
||||||
| Exceptions that occur while this calls :meth:`~object.__hash__` and | ||||||
|
|
@@ -143,6 +166,9 @@ Dictionary objects | |||||
| Calling this API without an :term:`attached thread state` had been allowed for historical | ||||||
| reason. It is no longer allowed. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: PyObject* PyDict_GetItemWithError(PyObject *p, PyObject *key) | ||||||
|
|
||||||
|
|
@@ -151,6 +177,9 @@ Dictionary objects | |||||
| occurred. Return ``NULL`` **without** an exception set if the key | ||||||
| wasn't present. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: PyObject* PyDict_GetItemString(PyObject *p, const char *key) | ||||||
|
|
||||||
|
|
@@ -166,6 +195,9 @@ Dictionary objects | |||||
| Prefer using the :c:func:`PyDict_GetItemWithError` function with your own | ||||||
| :c:func:`PyUnicode_FromString` *key* instead. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: int PyDict_GetItemStringRef(PyObject *p, const char *key, PyObject **result) | ||||||
|
|
||||||
|
|
@@ -175,6 +207,9 @@ Dictionary objects | |||||
|
|
||||||
| .. versionadded:: 3.13 | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: PyObject* PyDict_SetDefault(PyObject *p, PyObject *key, PyObject *defaultobj) | ||||||
|
|
||||||
|
|
@@ -238,17 +273,32 @@ Dictionary objects | |||||
|
|
||||||
| Return a :c:type:`PyListObject` containing all the items from the dictionary. | ||||||
|
|
||||||
| The first argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: PyObject* PyDict_Keys(PyObject *p) | ||||||
|
|
||||||
| Return a :c:type:`PyListObject` containing all the keys from the dictionary. | ||||||
|
|
||||||
| The first argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: PyObject* PyDict_Values(PyObject *p) | ||||||
|
|
||||||
| Return a :c:type:`PyListObject` containing all the values from the dictionary | ||||||
| *p*. | ||||||
|
|
||||||
| The first argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: Py_ssize_t PyDict_Size(PyObject *p) | ||||||
|
|
||||||
|
|
@@ -257,11 +307,19 @@ Dictionary objects | |||||
| Return the number of items in the dictionary. This is equivalent to | ||||||
| ``len(p)`` on a dictionary. | ||||||
|
|
||||||
| The argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: Py_ssize_t PyDict_GET_SIZE(PyObject *p) | ||||||
|
|
||||||
| Similar to :c:func:`PyDict_Size`, but without error checking. | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
|
|
||||||
| .. c:function:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) | ||||||
|
|
||||||
|
|
@@ -276,6 +334,8 @@ Dictionary objects | |||||
| value represents offsets within the internal dictionary structure, and | ||||||
| since the structure is sparse, the offsets are not consecutive. | ||||||
|
|
||||||
| The first argument can be a :class:`dict` or a :class:`frozendict`. | ||||||
|
|
||||||
| For example:: | ||||||
|
|
||||||
| PyObject *key, *value; | ||||||
|
|
@@ -329,6 +389,9 @@ Dictionary objects | |||||
| :term:`strong reference <strong reference>` (for example, using | ||||||
| :c:func:`Py_NewRef`). | ||||||
|
|
||||||
| .. versionchanged:: next | ||||||
| Accept also :class:`frozendict`. | ||||||
|
|
||||||
| .. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override) | ||||||
|
|
||||||
| Iterate over mapping object *b* adding key-value pairs to dictionary *a*. | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.