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

Nick Coghlan ncoghlan at gmail.com
Fri Nov 8 00🔞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 PyDictDelItemId() function, similar to PyDictDelItemString() 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 @@ PyAPIFUNC(int) PyDictSetItemString(PyObject *dp, const char *key, PyObject *item); PyAPIFUNC(int) PyDictSetItemId(PyObject *dp, struct PyIdentifier *key, PyObject *item); PyAPIFUNC(int) PyDictDelItemString(PyObject *dp, const char *key); +PyAPIFUNC(int) PyDictDelItemId(PyObject *mp, struct PyIdentifier *key);

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

Cheers, Nick.

#ifndef PyLIMITEDAPI int PyObjectDictSetItem(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 +PyDictDelItemId(PyObject *v, PyIdentifier *key) +{ + PyObject kv = PyUnicodeFromId(key); / borrowed */ + if (kv == NULL) + return -1; + return PyDictDelItem(v, kv); +} + +int PyDictDelItemString(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-dev/attachments/20131108/969ccb62/attachment.html>



More information about the Python-Dev mailing list