mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Expose dict_contains() and PyDict_Contains() with is about 10% faster
than PySequence_Contains() and more clearly applicable to dicts. Apply the new function in setobject.c where __contains__ checking is ubiquitous.
This commit is contained in:
parent
3972457de7
commit
bc0f2ab9bb
5 changed files with 26 additions and 12 deletions
|
@ -1808,6 +1808,14 @@ format.
|
|||
Empties an existing dictionary of all key-value pairs.
|
||||
\end{cfuncdesc}
|
||||
|
||||
\begin{cfuncdesc}{int}{PyDict_Contains}{PyObject *p, PyObject *key}
|
||||
Determine if dictionary \var{p} contains \var{key}. If an item
|
||||
in \var{p} is matches \var{key}, return \code{1}, otherwise return
|
||||
\code{0}. On error, return \code{-1}. This is equivalent to the
|
||||
Python expression \samp{\var{key} in \var{p}}.
|
||||
\versionadded{2.4}
|
||||
\end{cfuncdesc}
|
||||
|
||||
\begin{cfuncdesc}{PyObject*}{PyDict_Copy}{PyObject *p}
|
||||
Returns a new dictionary that contains the same key-value pairs as
|
||||
\var{p}.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue