[Python-checkins] python/dist/src/Python bltinmodule.c,2.257,2.258
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Wed, 05 Jun 2002 16:12:47 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv2645/Python
Modified Files:
bltinmodule.c
Log Message:
Skip Montanaro's patch, SF 559833, exposing xrange type in builtins.
Also, added more regression tests to cover the new type and test its
conformity with range().
Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.257
retrieving revision 2.258
diff -C2 -d -r2.257 -r2.258
*** bltinmodule.c 31 May 2002 19:58:02 -0000 2.257
--- bltinmodule.c 5 Jun 2002 23:12:45 -0000 2.258
***************
*** 1366,1411 ****
static PyObject *
- builtin_xrange(PyObject *self, PyObject *args)
- {
- long ilow = 0, ihigh = 0, istep = 1;
- long n;
-
- if (PyTuple_Size(args) <= 1) {
- if (!PyArg_ParseTuple(args,
- "l;xrange() requires 1-3 int arguments",
- &ihigh))
- return NULL;
- }
- else {
- if (!PyArg_ParseTuple(args,
- "ll|l;xrange() requires 1-3 int arguments",
- &ilow, &ihigh, &istep))
- return NULL;
- }
- if (istep == 0) {
- PyErr_SetString(PyExc_ValueError, "xrange() arg 3 must not be zero");
- return NULL;
- }
- if (istep > 0)
- n = get_len_of_range(ilow, ihigh, istep);
- else
- n = get_len_of_range(ihigh, ilow, -istep);
- if (n < 0) {
- PyErr_SetString(PyExc_OverflowError,
- "xrange() result has too many items");
- return NULL;
- }
- return PyRange_New(ilow, n, istep, 1);
- }
-
- static char xrange_doc[] =
- "xrange([start,] stop[, step]) -> xrange object\n\
- \n\
- Like range(), but instead of returning a list, returns an object that\n\
- generates the numbers in the range on demand. This is slightly slower\n\
- than range() but more memory efficient.";
-
-
- static PyObject *
builtin_raw_input(PyObject *self, PyObject *args)
{
--- 1366,1369 ----
***************
*** 1861,1865 ****
#endif
{"vars", builtin_vars, METH_VARARGS, vars_doc},
- {"xrange", builtin_xrange, METH_VARARGS, xrange_doc},
{"zip", builtin_zip, METH_VARARGS, zip_doc},
{NULL, NULL},
--- 1819,1822 ----
***************
*** 1910,1913 ****
--- 1867,1871 ----
SETBUILTIN("tuple", &PyTuple_Type);
SETBUILTIN("type", &PyType_Type);
+ SETBUILTIN("xrange", &PyRange_Type);
/* Note that open() is just an alias of file(). */