functional
Module for functional programming utilities.
Functions:
| Name | Description |
|---|---|
apply_in_parallel |
Apply a function to multiple items' values, one worker thread per item. |
sequential |
Compose functions sequentially. |
apply_in_parallel
¶
apply_in_parallel(
func: Callable[..., R],
items: Mapping[K, V],
*extra_args: object,
max_workers: int,
) -> dict[K, R]
Apply a function to multiple items' values, one worker thread per item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Callable[..., R]
|
A function taking one item's value (plus any |
required |
|
Mapping[K, V]
|
A mapping of key to value to pass to |
required |
|
object
|
Additional positional arguments passed to every |
required |
|
int
|
The upper bound on worker threads to use, further capped by |
required |
Returns:
| Type | Description |
|---|---|
dict[K, R]
|
A mapping of key to |
sequential
¶
Compose functions sequentially.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Callable[..., Any]
|
The functions to compose. The first function may take any arguments, but the rest must take the output of the previous function. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no functions are passed. |
Returns:
| Type | Description |
|---|---|
Callable[..., Any]
|
A function that composes the given functions. |