[Python-checkins] cpython: Issue #19512: Add a new _PyDict_DelItemId() function, similar to

Nick Coghlan ncoghlan at gmail.com
Fri Nov 8 00:18:45 CET 2013


On 7 Nov 2013 04:06, "victor.stinner" <python-checkins at python.org> wrote:
>
> http://hg.python.org/cpython/rev/69071054b42f
> changeset:   86968:69071054b42f
> user:        Victor Stinner <victor.stinner at gmail.com>
> date:        Wed Nov 06 18:58:22 2013 +0100
> summary:
>   Issue #19512: Add a new _PyDict_DelItemId() function, similar to
> PyDict_DelItemString() but using an identifier for the key
>
> files:
>   Include/dictobject.h |  1 +
>   Objects/dictobject.c |  9 +++++++++
>   2 files changed, 10 insertions(+), 0 deletions(-)
>
>
> diff --git a/Include/dictobject.h b/Include/dictobject.h
> --- a/Include/dictobject.h
> +++ b/Include/dictobject.h
> @@ -109,6 +109,7 @@
>  PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key,
PyObject *item);
>  PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier
*key, PyObject *item);
>  PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
> +PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier
*key);

As a private API, this shouldn't be part of the stable ABI.

Cheers,
Nick.

>
>  #ifndef Py_LIMITED_API
>  int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject
*name, PyObject *value);
> diff --git a/Objects/dictobject.c b/Objects/dictobject.c
> --- a/Objects/dictobject.c
> +++ b/Objects/dictobject.c
> @@ -2736,6 +2736,15 @@
>  }
>
>  int
> +_PyDict_DelItemId(PyObject *v, _Py_Identifier *key)
> +{
> +    PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
> +    if (kv == NULL)
> +        return -1;
> +    return PyDict_DelItem(v, kv);
> +}
> +
> +int
>  PyDict_DelItemString(PyObject *v, const char *key)
>  {
>      PyObject *kv;
>
> --
> Repository URL: http://hg.python.org/cpython
>
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> https://mail.python.org/mailman/listinfo/python-checkins
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-checkins/attachments/20131108/969ccb62/attachment.html>


More information about the Python-checkins mailing list