MCPcopy Create free account
hub / github.com/ActiveState/code / imap

Method imap

recipes/Python/576519_Thread_pool_same_API/recipe-576519.py:129–145  ·  view source on GitHub ↗

An equivalent of itertools.imap(). The chunksize argument is the same as the one used by the map() method. For very long iterables using a large value for chunksize can make make the job complete much faster than using the default value of 1. Also i

(self, func, iterable, chunksize=1)

Source from the content-addressed store, hash-verified

127 return self.map_async(func, iterable, chunksize).get()
128
129 def imap(self, func, iterable, chunksize=1):
130 """
131 An equivalent of itertools.imap().
132
133 The chunksize argument is the same as the one used by the
134 map() method. For very long iterables using a large value for
135 chunksize can make make the job complete much faster than
136 using the default value of 1.
137
138 Also if chunksize is 1 then the next() method of the iterator
139 returned by the imap() method has an optional timeout
140 parameter: next(timeout) will raise processing.TimeoutError if
141 the result cannot be returned within timeout seconds.
142 """
143 collector = OrderedResultCollector(as_iterator=True)
144 self._create_sequences(func, iterable, chunksize, collector)
145 return iter(collector)
146
147 def imap_unordered(self, func, iterable, chunksize=1):
148 """The same as imap() except that the ordering of the results

Callers 12

_testFunction · 0.95
maybe_ordFunction · 0.45
recipe-305318.pyFile · 0.45
anyTrueFunction · 0.45
__iter__Method · 0.45
extendMethod · 0.45
primes_less_thanFunction · 0.45
first_N_primesFunction · 0.45
primes_less_thanFunction · 0.45
first_N_primesFunction · 0.45
imapmethodFunction · 0.45
alldifferentFunction · 0.45

Calls 2

_create_sequencesMethod · 0.95

Tested by

no test coverage detected