File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
doc/data/messages/u/use-yield-from Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 11:code: `yield from ` can be thought of as removing the intermediary (your for loop) between the function caller and the
2- requested generator. This enables the caller to directly communicate with the generator (e.g. :code: `send() `).
2+ requested generator. This enables the caller to directly communicate with the generator (e.g. using :code: `send() `).
33This communication is not possible when manually yielding each element one by one in a loop.
44
5- PEP 380 describes the possibility of adding optimizations specific to :code: `yield from `, as of the time of writing,
6- it can't be confirmed that such optimizations have been implemented. The following snippet still shows that while
7- probably negligible, a performance improvement can exist simply because of the removed overhead .
5+ PEP 380 describes the possibility of adding optimizations specific to :code: `yield from `. It looks like said
6+ implementations have not been implemented as of the time of writing. Even without said optimizations, the following
7+ snippets shows that :code: ` yield from ` is marginally faster .
88
99.. code-block :: sh
1010
You can’t perform that action at this time.
0 commit comments