PEP 798: Unpacking in Comprehensions

I think the biggest remaining question here is about how * unpacking should behave for synchronous versus async generator expressions (current proposal is here in the draft). I wanted to open this back up since there’s some nuance to it and I’m still curious for more opinions if I can gather them, so here’s a poll that I think reflects the main options (but feel free to follow up if I’ve missed something).

Regardless of the outcome here, I’m planning on adding a note stating that this question should be revisited if and when async generator expressions gain support for yield from; so the question is really about what the behavior should be in the meantime).

  • Keep the existing semantics (sync uses yield from, async uses an explicit loop)
  • Replace sync version in current PEP with an explicit loop instead of yield from (both sync and async use explicit loops)
  • Make both sync and async use something like yield from (sync uses yield from, we implement an equivalent to yield from for the async case)
  • Don’t allow unpacking in async genexps at all until they support yield from
  • Don’t allow unpacking in any genexps because of this ambiguity
  • Something else
  • I don’t care / Show the results
0 voters

Aside from this question (and probably adding something to “Rejected Alternative Proposals” depending on where this ends up), I’m not anticipating a lot of change in the PEP from its current form based on the feedback so far; but if there are other points that people want to push back on, more feedback is still welcome about other aspects of the PEP as well :slight_smile:.

2 Likes