@@ -1597,80 +1597,6 @@ For example, range(4) returns [0, 1, 2, 3]. The end point is omitted!\n\
15971597These are exactly the valid indices for a list of 4 elements." );
15981598
15991599
1600- static PyObject *
1601- builtin_reduce (PyObject * self , PyObject * args )
1602- {
1603- PyObject * seq , * func , * result = NULL , * it ;
1604-
1605- if (!PyArg_UnpackTuple (args , "reduce" , 2 , 3 , & func , & seq , & result ))
1606- return NULL ;
1607- if (result != NULL )
1608- Py_INCREF (result );
1609-
1610- it = PyObject_GetIter (seq );
1611- if (it == NULL ) {
1612- PyErr_SetString (PyExc_TypeError ,
1613- "reduce() arg 2 must support iteration" );
1614- Py_XDECREF (result );
1615- return NULL ;
1616- }
1617-
1618- if ((args = PyTuple_New (2 )) == NULL )
1619- goto Fail ;
1620-
1621- for (;;) {
1622- PyObject * op2 ;
1623-
1624- if (args -> ob_refcnt > 1 ) {
1625- Py_DECREF (args );
1626- if ((args = PyTuple_New (2 )) == NULL )
1627- goto Fail ;
1628- }
1629-
1630- op2 = PyIter_Next (it );
1631- if (op2 == NULL ) {
1632- if (PyErr_Occurred ())
1633- goto Fail ;
1634- break ;
1635- }
1636-
1637- if (result == NULL )
1638- result = op2 ;
1639- else {
1640- PyTuple_SetItem (args , 0 , result );
1641- PyTuple_SetItem (args , 1 , op2 );
1642- if ((result = PyEval_CallObject (func , args )) == NULL )
1643- goto Fail ;
1644- }
1645- }
1646-
1647- Py_DECREF (args );
1648-
1649- if (result == NULL )
1650- PyErr_SetString (PyExc_TypeError ,
1651- "reduce() of empty sequence with no initial value" );
1652-
1653- Py_DECREF (it );
1654- return result ;
1655-
1656- Fail :
1657- Py_XDECREF (args );
1658- Py_XDECREF (result );
1659- Py_DECREF (it );
1660- return NULL ;
1661- }
1662-
1663- PyDoc_STRVAR (reduce_doc ,
1664- "reduce(function, sequence[, initial]) -> value\n\
1665- \n\
1666- Apply a function of two arguments cumulatively to the items of a sequence,\n\
1667- from left to right, so as to reduce the sequence to a single value.\n\
1668- For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates\n\
1669- ((((1+2)+3)+4)+5). If initial is present, it is placed before the items\n\
1670- of the sequence in the calculation, and serves as a default when the\n\
1671- sequence is empty." );
1672-
1673-
16741600static PyObject *
16751601builtin_reload (PyObject * self , PyObject * v )
16761602{
@@ -2071,7 +1997,6 @@ static PyMethodDef builtin_methods[] = {
20711997 {"ord" , builtin_ord , METH_O , ord_doc },
20721998 {"pow" , builtin_pow , METH_VARARGS , pow_doc },
20731999 {"range" , builtin_range , METH_VARARGS , range_doc },
2074- {"reduce" , builtin_reduce , METH_VARARGS , reduce_doc },
20752000 {"reload" , builtin_reload , METH_O , reload_doc },
20762001 {"repr" , builtin_repr , METH_O , repr_doc },
20772002 {"round" , (PyCFunction )builtin_round , METH_VARARGS | METH_KEYWORDS , round_doc },
0 commit comments