Return with value allowed in generators but not async generators?

Why is return with value allowed in generators but not async generators?
The returned value of custom generators is passed as the message to the thrown StopIteration, so why isn’t that analogous to async generators?
Even though StopAsyncIteration is not necessarily sequentially stopping the iteration in async generators, why is this behaviour not analogous between generators and async generators?

1 Like

It is explicitely stated in PEP 525:

It is a SyntaxError to have a non-empty return statement in an asynchronous generator.

But I couldn’t find the rationale for this limitation, so I’m curious too! :smile:

1 Like