[Python-checkins] python/dist/src/Modules itertoolsmodule.c,1.7,1.8

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Mon, 17 Mar 2003 00:22:59 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv29413/Modules

Modified Files:
	itertoolsmodule.c 
Log Message:
Created PyObject_GenericGetIter().
Factors out the common case of returning self.



Index: itertoolsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/itertoolsmodule.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** itertoolsmodule.c	1 Mar 2003 01:48:24 -0000	1.7
--- itertoolsmodule.c	17 Mar 2003 08:22:57 -0000	1.8
***************
*** 106,116 ****
  }
  
- static PyObject *
- cycle_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(cycle_doc,
  "cycle(iterable) --> cycle object\n\
--- 106,109 ----
***************
*** 148,152 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)cycle_getiter,	/* tp_iter */
  	(iternextfunc)cycle_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 141,145 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)cycle_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 262,272 ****
  }
  
- static PyObject *
- dropwhile_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(dropwhile_doc,
  "dropwhile(predicate, iterable) --> dropwhile object\n\
--- 255,258 ----
***************
*** 304,308 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)dropwhile_getiter,	/* tp_iter */
  	(iternextfunc)dropwhile_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 290,294 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)dropwhile_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 417,427 ****
  }
  
- static PyObject *
- takewhile_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(takewhile_doc,
  "takewhile(predicate, iterable) --> takewhile object\n\
--- 403,406 ----
***************
*** 459,463 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)takewhile_getiter,	/* tp_iter */
  	(iternextfunc)takewhile_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 438,442 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)takewhile_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 590,600 ****
  }
  
- static PyObject *
- islice_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(islice_doc,
  "islice(iterable, [start,] stop [, step]) --> islice object\n\
--- 569,572 ----
***************
*** 636,640 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)islice_getiter,	/* tp_iter */
  	(iternextfunc)islice_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 608,612 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)islice_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 740,750 ****
  }
  
- static PyObject *
- starmap_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(starmap_doc,
  "starmap(function, sequence) --> starmap object\n\
--- 712,715 ----
***************
*** 782,786 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)starmap_getiter,	/* tp_iter */
  	(iternextfunc)starmap_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 747,751 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)starmap_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 931,941 ****
  }
  
- static PyObject *
- imap_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(imap_doc,
  "imap(func, *iterables) --> imap object\n\
--- 896,899 ----
***************
*** 976,980 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)imap_getiter,	/* tp_iter */
  	(iternextfunc)imap_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 934,938 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)imap_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 1075,1085 ****
  }
  
- static PyObject *
- chain_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(chain_doc,
  "chain(*iterables) --> chain object\n\
--- 1033,1036 ----
***************
*** 1118,1122 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)chain_getiter,	/* tp_iter */
  	(iternextfunc)chain_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 1069,1073 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)chain_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 1232,1242 ****
  }
  
- static PyObject *
- ifilter_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(ifilter_doc,
  "ifilter(function or None, sequence) --> ifilter object\n\
--- 1183,1186 ----
***************
*** 1274,1278 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)ifilter_getiter,	/* tp_iter */
  	(iternextfunc)ifilter_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 1218,1222 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)ifilter_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 1388,1398 ****
  }
  
- static PyObject *
- ifilterfalse_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(ifilterfalse_doc,
  "ifilterfalse(function or None, sequence) --> ifilterfalse object\n\
--- 1332,1335 ----
***************
*** 1430,1434 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)ifilterfalse_getiter,	/* tp_iter */
  	(iternextfunc)ifilterfalse_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 1367,1371 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)ifilterfalse_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 1480,1490 ****
  }
  
- static PyObject *
- count_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(count_doc,
  "count([firstval]) --> count object\n\
--- 1417,1420 ----
***************
*** 1521,1525 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)count_getiter,	/* tp_iter */
  	(iternextfunc)count_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 1451,1455 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)count_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 1666,1676 ****
  }
  
- static PyObject *
- izip_getiter(PyObject *lz)
- {
- 	Py_INCREF(lz);
- 	return lz;
- }
- 
  PyDoc_STRVAR(izip_doc,
  "izip(iter1 [,iter2 [...]]) --> izip object\n\
--- 1596,1599 ----
***************
*** 1712,1716 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)izip_getiter,	/* tp_iter */
  	(iternextfunc)izip_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 1635,1639 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)izip_next,	/* tp_iternext */
  	0,				/* tp_methods */
***************
*** 1785,1795 ****
  }
  
- static PyObject *
- repeat_getiter(PyObject *ro)
- {
- 	Py_INCREF(ro);
- 	return ro;
- }
- 
  PyDoc_STRVAR(repeat_doc,
  "repeat(element [,times]) -> create an iterator which returns the element\n\
--- 1708,1711 ----
***************
*** 1826,1830 ****
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	(getiterfunc)repeat_getiter,	/* tp_iter */
  	(iternextfunc)repeat_next,	/* tp_iternext */
  	0,				/* tp_methods */
--- 1742,1746 ----
  	0,				/* tp_richcompare */
  	0,				/* tp_weaklistoffset */
! 	PyObject_GenericGetIter,	/* tp_iter */
  	(iternextfunc)repeat_next,	/* tp_iternext */
  	0,				/* tp_methods */