libearth.compat.parallel — Threading-related compatibility layer¶
-
libearth.compat.parallel.cpu_count()¶ Get the number of CPU cores.
Returns: the number of cpu cores Return type: numbers.Integral
-
libearth.compat.parallel.parallel_map(pool_size, function, iterable, *iterables)¶ Parallel vesion of builtin
map()except of some differences:- It takes a more argument at first:
pool_size. - The function applications will be done in parallel.
- The order of arguments to results are not maintained. You should treat these as a set.
- The result is a lazy iterable. Although the function immediately returns an iterable, it might block if some results are not completely ready when it’s iterated.
Parameters: - pool_size (
numbers.Integral) – the number of workers - function (
collections.Callable) – the function to apply iterables as its arguments - iterable (
collections.Iterable) – function argument values
Returns: a promise iterable to future results
Return type: collections.IterableChanged in version 0.1.1: Errored values are raised at the lastest.
- It takes a more argument at first: