[Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.23,
1.24
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Oct 26 09:25:58 EST 2003
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv1431/Modules
Modified Files:
itertoolsmodule.c
Log Message:
Minor improvements to itertools.tee():
* tee object is no longer subclassable
* independent iterators renamed to "itertools.tee_iterator"
* fixed doc string typo and added entry in the module doc string
Index: itertoolsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/itertoolsmodule.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** itertoolsmodule.c 25 Oct 2003 06:37:47 -0000 1.23
--- itertoolsmodule.c 26 Oct 2003 14:25:56 -0000 1.24
***************
*** 114,123 ****
}
! PyDoc_STRVAR(ii_doc, "Independent iterators linked to a tee() object.");
static PyTypeObject ii_type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
! "itertools.independent_iterator", /* tp_name */
sizeof(iiobject), /* tp_basicsize */
0, /* tp_itemsize */
--- 114,123 ----
}
! PyDoc_STRVAR(ii_doc, "Independent iterator created by tee(iterable).");
static PyTypeObject ii_type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
! "itertools.tee_iterator", /* tp_name */
sizeof(iiobject), /* tp_basicsize */
0, /* tp_itemsize */
***************
*** 174,178 ****
if (outbasket == NULL) goto fail;
! to = (teeobject *)type->tp_alloc(type, 0);
if (to == NULL) goto fail;
--- 174,178 ----
if (outbasket == NULL) goto fail;
! to = PyObject_GC_New(teeobject, &tee_type);
if (to == NULL) goto fail;
***************
*** 182,185 ****
--- 182,186 ----
to->save_mode = 1;
to->num_seen = 0;
+ PyObject_GC_Track(to);
/* create independent iterators */
***************
*** 213,217 ****
Py_XDECREF(to->outbasket);
Py_XDECREF(to->it);
! to->ob_type->tp_free(to);
}
--- 214,218 ----
Py_XDECREF(to->outbasket);
Py_XDECREF(to->it);
! PyObject_GC_Del(to);
}
***************
*** 242,246 ****
"tee(iterable) --> (it1, it2)\n\
\n\
! Split the iterable into to independent iterables.");
static PyTypeObject tee_type = {
--- 243,247 ----
"tee(iterable) --> (it1, it2)\n\
\n\
! Split the iterable into two independent iterables.");
static PyTypeObject tee_type = {
***************
*** 263,271 ****
0, /* tp_call */
0, /* tp_str */
! PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
! Py_TPFLAGS_BASETYPE, /* tp_flags */
tee_doc, /* tp_doc */
(traverseproc)tee_traverse, /* tp_traverse */
--- 264,271 ----
0, /* tp_call */
0, /* tp_str */
! 0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
tee_doc, /* tp_doc */
(traverseproc)tee_traverse, /* tp_traverse */
***************
*** 286,290 ****
0, /* tp_alloc */
tee_new, /* tp_new */
- PyObject_GC_Del, /* tp_free */
};
--- 286,289 ----
***************
*** 2093,2096 ****
--- 2092,2096 ----
imap(fun, p, q, ...) --> fun(p0, q0), fun(p1, q1), ...\n\
starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n\
+ tee(it) --> (it1, it2) splits one iterator into two \n\
chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ... \n\
takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n\
More information about the Python-checkins
mailing list