Added neat file example to imap docs.
This commit is contained in:
@@ -151,6 +151,14 @@ class GreenPool(object):
|
|||||||
def imap(self, function, *iterables):
|
def imap(self, function, *iterables):
|
||||||
"""This is the same as :func:`itertools.imap`, and has the same
|
"""This is the same as :func:`itertools.imap`, and has the same
|
||||||
concurrency and memory behavior as :meth:`starmap`.
|
concurrency and memory behavior as :meth:`starmap`.
|
||||||
|
|
||||||
|
It's quite convenient for, e.g., farming out jobs from a file::
|
||||||
|
|
||||||
|
def worker(line):
|
||||||
|
return do_something(line)
|
||||||
|
pool = GreenPool()
|
||||||
|
for result in pool.imap(worker, open("filename", 'r')):
|
||||||
|
print result
|
||||||
"""
|
"""
|
||||||
return self.starmap(function, itertools.izip(*iterables))
|
return self.starmap(function, itertools.izip(*iterables))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user