Skip to content

BUILD_INTERPOLATION and BUILD_TEMPLATE perform unnecessary refcount operations #145860

Open

Description

@markshannon

Feature or enhancement

Proposal:

BUILD_INTERPOLATION and BUILD_TEMPLATE call _PyInterpolation_Build and _PyTemplate_Build respectively, and then decref their arguments. All other BUILD instructions call a "steal" function, to avoid the unnecessary incref then decref. BUILD_INTERPOLATION and BUILD_TEMPLATE should do the same.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added
    type-feature
    on Mar 12, 2026
  2. added
    performance
    interpreter-core
    on Mar 12, 2026
  3. akanil18 commented on Mar 13, 2026

    @akanil18

    Hi I would love to work on this issue.

    I understand the goal is to optimize BUILD_INTERPOLATION and BUILD_TEMPLATE by using "steal" functions to avoid the unnecessary incref and decref operations, bringing them in line with how other BUILD instructions handle their arguments.

    Could you please assign this issue to me, or let me know if it's okay for me to just go ahead and open a PR? Thanks

  4. sergey-miryanov commented on Mar 14, 2026

    @sergey-miryanov
    Contributor

    I would suggest you wait answer from Mark before start doing this.

  5. added 2 commits that reference this issue on Apr 7, 2026
  6. added 2 commits that reference this issue on Nov 24, 2026
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-coreperformancetype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions