You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "liferoad (via GitHub)" <gi...@apache.org> on 2023/03/18 16:26:26 UTC

[GitHub] [beam] liferoad commented on a diff in pull request #25893: Recommend `yield from` for emitting elements from iterables.

liferoad commented on code in PR #25893:
URL: https://github.com/apache/beam/pull/25893#discussion_r1141048123


##########
website/www/site/content/en/documentation/programming-guide.md:
##########
@@ -955,9 +955,10 @@ the actual processing logic. You don't need to manually extract the elements
 from the input collection; the Beam SDKs handle that for you. Your `process` method
 should accept an argument `element`, which is the input element, and return an
 iterable with its output values. You can accomplish this by emitting individual
-elements with `yield` statements. You can also use a `return` statement
-with an iterable, like a list or a generator. Don't mix `yield` and
-`return` statements in the same `process` method - this leads to [undefined behavior](https://github.com/apache/beam/issues/22969).
+elements with `yield` statements, and use `yield from` to emit all elements from
+an iterable, such as a list or a generator. Using `return` statement
+with an iterable is also acceptable as long as you don't mix `yield` and

Review Comment:
   `yield` could cause the this error `cannot pickle 'generator' object` for some cases. This is why I did not update the doc in https://github.com/apache/beam/pull/25743



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org