Skip to content

Commit 0cae4e6

Browse files
committed
README: revamp concurrency
1 parent c1d0001 commit 0cae4e6

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ assert list(integer_strings) == ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9
102102
```
103103
</details>
104104

105+
## concurrency
106+
107+
> [!NOTE]
108+
> By default, all the concurrency modes presented below yield results in the upstream order (FIFO). Set the parameter `ordered=False` to yield results as they become available (***First Done, First Out***).
109+
105110
### thread-based concurrency
106111

107112
> Applies the transformation via `concurrency` threads:
@@ -122,8 +127,6 @@ assert list(pokemon_names) == ['bulbasaur', 'ivysaur', 'venusaur']
122127
```
123128
</details>
124129

125-
> Preserves the upstream order by default (FIFO), but you can set `ordered=False` for ***First Done First Out***.
126-
127130
> [!NOTE]
128131
> `concurrency` is also the size of the buffer containing not-yet-yielded results. **If the buffer is full, the iteration over the upstream is paused** until a result is yielded from the buffer.
129132
@@ -171,7 +174,7 @@ asyncio.get_event_loop().run_until_complete(http_async_client.aclose())
171174
```
172175
</details>
173176

174-
### starmap
177+
## "starmap"
175178

176179
> The `star` function decorator transforms a function that takes several positional arguments into a function that takes a tuple:
177180
@@ -208,18 +211,13 @@ assert state == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
208211
```
209212
</details>
210213

211-
### thread-based concurrency
212-
213-
> Like `.map` it has an optional `concurrency` parameter.
214-
> Preserves the upstream order by default (FIFO), but you can set `ordered=False` for ***First Done First Out***.
215-
216-
### process-based concurrency
217-
218-
> Like for `.map`, set the parameter `via="process"`.
219-
220-
### `asyncio`-based concurrency
214+
## concurrency
221215

222-
> Like `.map` it has a sibling `.aforeach` operation for async.
216+
> Similar to `.map`:
217+
> - set the `concurrency` parameter for **thread-based concurrency**
218+
> - set `via="process"` for **process-based concurrency**
219+
> - use the sibling `.aforeach` operation for **`asyncio`-based concurrency**
220+
> - set `ordered=False` for ***First Done First Out***
223221
224222
# `.group`
225223

0 commit comments

Comments
 (0)