Skip to content

[mypyc] Use generator helper fast path on resume - #21954

Merged
JukkaL merged 2 commits into
masterfrom
mypyc-async-1
Sep 7, 2026
Merged

[mypyc] Use generator helper fast path on resume#21954
JukkaL merged 2 commits into
masterfrom
mypyc-async-1

Conversation

@JukkaL

@JukkaL JukkaL commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Extend the direct helper method fast path for statically known native
generators and coroutines to resumes after suspension. This avoids
generic send dispatch and StopIteration handling on completion.

The savings compound in deep native coroutine chains, where each
await frame would otherwise pay this overhead.

In an (unrealistic) microbenchmark this made a long await chain
1.8x faster. With event loop overhead included and an asyncio.sleep(0),
call, the improvement in modified microbenchmark was about 10%
when using uvloop.

I used coding agent assist.

Extend the direct helper fast path for statically known native
generators and coroutines to resumes after suspension. This avoids
generic send dispatch and StopIteration handling on completion.

The savings compound in deep native coroutine chains, where each
await frame would otherwise pay this overhead.
@JukkaL
JukkaL merged commit 3ca6857 into master Sep 7, 2026
18 checks passed
@JukkaL
JukkaL deleted the mypyc-async-1 branch September 7, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants