[Python-checkins] python/dist/src/Modules collectionsmodule.c, 1.13, 1.14 (original) (raw)
rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Wed May 12 16:55:59 EDT 2004
- Previous message: [Python-checkins] python/dist/src/PCbuild BUILDno.txt,1.56,1.57
- Next message: [Python-checkins] python/dist/src/Doc/lib libcollections.tex, 1.8, 1.9
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9217/Modules
Modified Files: collectionsmodule.c Log Message: Make sure "del d[n]" is properly supported. Was necessary because the same method that implements setitem also implements delitem. Also, there were several good use cases (removing items from a queue and implementing Forth style stack ops).
Index: collectionsmodule.c
RCS file: /cvsroot/python/python/dist/src/Modules/collectionsmodule.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** collectionsmodule.c 12 Apr 2004 18:10:01 -0000 1.13 --- collectionsmodule.c 12 May 2004 20:55:42 -0000 1.14
*** 354,357 **** --- 354,395 ----
static int
- deque_del_item(dequeobject *deque, int i)
- {
PyObject *item=NULL, *minus_i=NULL, *plus_i=NULL;
int rv = -1;
assert (i >= 0 && i < deque->len);
minus_i = Py_BuildValue("(i)", -i);
if (minus_i == NULL)
goto fail;
plus_i = Py_BuildValue("(i)", i);
if (plus_i == NULL)
goto fail;
item = deque_rotate(deque, minus_i);
if (item == NULL)
goto fail;
Py_DECREF(item);
item = deque_popleft(deque, NULL);
if (item == NULL)
goto fail;
Py_DECREF(item);
item = deque_rotate(deque, plus_i);
if (item == NULL)
goto fail;
rv = 0;
- fail:
Py_XDECREF(item);
Py_XDECREF(minus_i);
Py_XDECREF(plus_i);
return rv;
- }
- static int deque_ass_item(dequeobject *deque, int i, PyObject *v) {
*** 365,368 **** --- 403,409 ---- return -1; }
if (v == NULL)
return deque_del_item(deque, i);
i += deque->leftindex; n = i / BLOCKLEN;
- Previous message: [Python-checkins] python/dist/src/PCbuild BUILDno.txt,1.56,1.57
- Next message: [Python-checkins] python/dist/src/Doc/lib libcollections.tex, 1.8, 1.9
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]