Skip to content

Fold PUSH_NULL; LOAD_CONST None into GET_AWAITABLE and GET_ANEXT #161875

Closed

Description

@asvetlov

Feature or enhancement

Since gh-145667, SEND takes (receiver, null_or_index, value). As a result, every await and every
async for iteration compiles to:

GET_AWAITABLE / GET_ANEXT
PUSH_NULL
LOAD_COMMON_CONSTANT     7 (None)
SEND

Both opcodes are only ever emitted immediately before this pair. I propose that they push the NULL and
the None themselves:

  • GET_AWAITABLE: (iterable -- iter, null, none)
  • GET_ANEXT: (aiter -- aiter, awaitable, null, none)

This saves two dispatches per await and per async for step. Opnames and opargs are unchanged and
SEND is untouched, so this is only a stack-effect change, like the one GET_ITER got in gh-132554.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added
    type-featureA feature request or enhancement
    performancePerformance or resource usage
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    and removed
    type-featureA feature request or enhancement
    performancePerformance or resource usage
    on Nov 12, 2026
  2. asvetlov commented on Nov 12, 2026

    @asvetlov
    ContributorAuthor

    Both changes are performance neutral. The boost is positive but very small; it probably doesn't affect any real program.

    The main reason (along with unification with GET_ITER etc.) is preparation for https://discuss.python.org/t/speed-up-async-functions-execution-by-40-by-postponing-a-coroutine-object-creation/109808
    Even if we don't decide to apply the postponed coroutine creation approach, the change still makes sense on its own.

  3. added 3 commits that reference this issue on Nov 19, 2026
  4. asvetlov commented on Nov 19, 2026

    @asvetlov
    ContributorAuthor

    Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions