On 7 Nov 2013 04:06, "victor.stinner" <python-check...@python.org> wrote: > > http://hg.python.org/cpython/rev/69071054b42f > changeset: 86968:69071054b42f > user: Victor Stinner <victor.stin...@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-check...@python.org > https://mail.python.org/mailman/listinfo/python-checkins >
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com