Skip to content

Use yield from instead of looping yield#6170

Merged
nateprewitt merged 1 commit intopsf:mainfrom
kkirsche:patch-1
Jun 29, 2022
Merged

Use yield from instead of looping yield#6170
nateprewitt merged 1 commit intopsf:mainfrom
kkirsche:patch-1

Conversation

@kkirsche
Copy link
Copy Markdown
Contributor

This merge request updates the stream yield functionality to use yield from instead of yield within a for loop. Because this is yielding from an iterable, we can use yield from which is not only slightly shorter but also on average 15% more performant than using yield inside of a loop. This is a result of some of the optimizations included as part of PEP 380

This merge request updates the stream yield functionality to use `yield from` instead of `yield` within a for loop. Because this is yielding from an iterable, we can use `yield from` which is not only slightly shorter but also on average 15% more performant than using `yield` inside of a loop. This is a result of some of the optimizations included as part of [PEP 380](https://peps.python.org/pep-0380/)
Copy link
Copy Markdown
Member

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it, thanks @kkirsche!

@nateprewitt nateprewitt merged commit 16b418b into psf:main Jun 29, 2022
@nateprewitt nateprewitt mentioned this pull request Jun 29, 2022
@kkirsche
Copy link
Copy Markdown
Contributor Author

Yep, part of splitting up #6165 to get past that...feedback

@kkirsche kkirsche deleted the patch-1 branch June 29, 2022 15:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants