From 5725d1eb034193e521dfe5febd675fb84e6acf5d Mon Sep 17 00:00:00 2001 From: Moshe Zadka Date: Thu, 30 Nov 2000 19:30:21 +0000 Subject: Backing out my changes. Improved version coming soon to a Source Forge near you! --- Doc/lib/libstdtypes.tex | 12 --------- Lib/test/test_types.py | 6 ----- Objects/dictobject.c | 72 ------------------------------------------------- 3 files changed, 90 deletions(-) diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex index b66de07..91dd675 100644 --- a/Doc/lib/libstdtypes.tex +++ b/Doc/lib/libstdtypes.tex @@ -783,12 +783,8 @@ arbitrary objects): \ttindex{has_key()} \ttindex{items()} \ttindex{keys()} - \ttindex{firstitem()} - \ttindex{firstkey()} \ttindex{update()} \ttindex{values()} - \ttindex{firstvalue()} - \ttindex{setdefault()} \ttindex{get()}} \begin{tableiii}{c|l|c}{code}{Operation}{Result}{Notes} @@ -808,19 +804,11 @@ arbitrary objects): \lineiii{\var{a}.items()} {a copy of \var{a}'s list of (\var{key}, \var{value}) pairs} {(2)} - \lineiii{\var{a}.firstitem()} - {a (\var{key}, \var{value}) pair, the first one in \var{a}.items()} - {(2)} \lineiii{\var{a}.keys()}{a copy of \var{a}'s list of keys}{(2)} - \lineiii{\var{a}.firstkey()} - {the first element in \var{a}.keys()} - {(2)} \lineiii{\var{a}.update(\var{b})} {\code{for k in \var{b}.keys(): \var{a}[k] = \var{b}[k]}} {(3)} \lineiii{\var{a}.values()}{a copy of \var{a}'s list of values}{(2)} - \lineiii{\var{a}.firstvalue()} - {the first element in \var{a}.values()} \lineiii{\var{a}.get(\var{k}\optional{, \var{x}})} {\code{\var{a}[\var{k}]} if \code{\var{a}.has_key(\var{k})}, else \var{x}} diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 06b001a..eec9e2d 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -265,9 +265,3 @@ if d['key'][0] <> 3: d.setdefault('key', []).append(4) if len(d['key']) <> 2: raise TestFailed, 'present {} setdefault, w/ 2nd arg' -if d.keys()[0] != d.firstkey(): - raise TestFailed, 'first key is not first in keys' -if d.values()[0] != d.firstvalue(): - raise TestFailed, 'first value is not first in values' -if d.items()[0] != d.firstitem(): - raise TestFailed, 'first item is not first in items' diff --git a/Objects/dictobject.c b/Objects/dictobject.c index ecc94cd..7be1c67 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -709,75 +709,6 @@ static PyMappingMethods dict_as_mapping = { }; static PyObject * -dict_firstkey(register dictobject *mp, PyObject *args) -{ - register int i; - - if (!PyArg_NoArgs(args)) - return NULL; - if (mp->ma_used == 0) { - PyErr_SetString(PyExc_ValueError, "empty dictionary"); - return NULL; - } - for (i = 0; i < mp->ma_size; i++) { - if (mp->ma_table[i].me_value != NULL) { - PyObject *key = mp->ma_table[i].me_key; - Py_INCREF(key); - return key; - } - } -} - -static PyObject * -dict_firstvalue(register dictobject *mp, PyObject *args) -{ - register int i; - - if (!PyArg_NoArgs(args)) - return NULL; - if (mp->ma_used == 0) { - PyErr_SetString(PyExc_ValueError, "empty dictionary"); - return NULL; - } - for (i = 0; i < mp->ma_size; i++) { - if (mp->ma_table[i].me_value != NULL) { - PyObject *value = mp->ma_table[i].me_value; - Py_INCREF(value); - return value; - } - } -} - -static PyObject * -dict_firstitem(register dictobject *mp, PyObject *args) -{ - register int i; - - if (!PyArg_NoArgs(args)) - return NULL; - if (mp->ma_used == 0) { - PyErr_SetString(PyExc_ValueError, "empty dictionary"); - return NULL; - } - for (i = 0; i < mp->ma_size; i++) { - if (mp->ma_table[i].me_value != NULL) { - PyObject *key = mp->ma_table[i].me_key; - PyObject *value = mp->ma_table[i].me_value; - PyObject *item = PyTuple_New(2); - if (item == NULL) { - return NULL; - } - Py_INCREF(key); - PyTuple_SetItem(item, 0, key); - Py_INCREF(value); - PyTuple_SetItem(item, 1, value); - return item; - } - } -} - - -static PyObject * dict_keys(register dictobject *mp, PyObject *args) { register PyObject *v; @@ -1231,9 +1162,6 @@ static PyMethodDef mapp_methods[] = { {"keys", (PyCFunction)dict_keys}, {"items", (PyCFunction)dict_items}, {"values", (PyCFunction)dict_values}, - {"firstkey", (PyCFunction)dict_firstkey}, - {"firstitem", (PyCFunction)dict_firstitem}, - {"firstvalue", (PyCFunction)dict_firstvalue}, {"update", (PyCFunction)dict_update}, {"clear", (PyCFunction)dict_clear}, {"copy", (PyCFunction)dict_copy}, -- cgit v0.12