summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-22 23:25:35 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-01-22 23:25:35 (GMT)
commit1dfde1ddc0e1980d67bd19e187252d4e52b4f7ce (patch)
tree365fcd0e0d95e4ff612ca7184d441e6184f8b203 /Modules
parent86def6cb2b8d6d8c7f239795fa7af57c97a5890d (diff)
downloadcpython-1dfde1ddc0e1980d67bd19e187252d4e52b4f7ce.zip
cpython-1dfde1ddc0e1980d67bd19e187252d4e52b4f7ce.tar.gz
cpython-1dfde1ddc0e1980d67bd19e187252d4e52b4f7ce.tar.bz2
Replace map(None, *iterables) with zip(*iterables).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/itertoolsmodule.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index d35c6b9..9e51663 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1490,31 +1490,6 @@ imap_traverse(imapobject *lz, visitproc visit, void *arg)
return 0;
}
-/*
-imap() is an iterator version of __builtins__.map() except that it does
-not have the None fill-in feature. That was intentionally left out for
-the following reasons:
-
- 1) Itertools are designed to be easily combined and chained together.
- Having all tools stop with the shortest input is a unifying principle
- that makes it easier to combine finite iterators (supplying data) with
- infinite iterators like count() and repeat() (for supplying sequential
- or constant arguments to a function).
-
- 2) In typical use cases for combining itertools, having one finite data
- supplier run out before another is likely to be an error condition which
- should not pass silently by automatically supplying None.
-
- 3) The use cases for automatic None fill-in are rare -- not many functions
- do something useful when a parameter suddenly switches type and becomes
- None.
-
- 4) If a need does arise, it can be met by __builtins__.map() or by
- writing: chain(iterable, repeat(None)).
-
- 5) Similar toolsets in Haskell and SML do not have automatic None fill-in.
-*/
-
static PyObject *
imap_next(imapobject *lz)
{
@@ -1536,8 +1511,6 @@ imap_next(imapobject *lz)
}
PyTuple_SET_ITEM(argtuple, i, val);
}
- if (lz->func == Py_None)
- return argtuple;
result = PyObject_Call(lz->func, argtuple, NULL);
Py_DECREF(argtuple);
return result;
@@ -1547,10 +1520,7 @@ PyDoc_STRVAR(imap_doc,
"imap(func, *iterables) --> imap object\n\
\n\
Make an iterator that computes the function using arguments from\n\
-each of the iterables. Like map() except that it returns\n\
-an iterator instead of a list and that it stops when the shortest\n\
-iterable is exhausted instead of filling in None for shorter\n\
-iterables.");
+each of the iterables. Stops when the shortest iterable is exhausted.");
static PyTypeObject imap_type = {
PyVarObject_HEAD_INIT(NULL, 0)