GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Avoid redundant reference counting of known Py_None values · Issue #159226 · python/cpython

Avoid redundant reference counting of known Py_None values #159226

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Avoid redundant reference counting of known Py_None values#159226
Copy link

Description

@ashm-dev
ashm-dev
opened on Oct 12, 2026
Issue body actions

Some C code in the interpreter and standard library still performs reference-counting operations on objects already known to be Py_None.

None has been immortal since Python 3.12. These operations do not change its reference count, but may still generate runtime checks. Similar cleanup was accepted in #103922, as part of #103906.

I propose extending that cleanup in a small series of focused PRs:

  • Remove explicit reference-counting operations on Py_None.
  • Remove operations on variables already checked to be Py_None.
  • Separately review call sites whose internal helper always returns None on success.

Compatibility with Limited API versions before 3.12 and tests specifically exercising reference-counting APIs would be preserved. Other immortal objects are outside the scope.

No Python-level behavior changes are intended.

Activity

  1. picnixz
    closed this as not plannedon Oct 12, 2026
  2. picnixz commented on Oct 12, 2026

    @picnixz
    picnixz
    on Oct 12, 2026
    Member
    More actions

    This has been discussed in the past and rejected as churn.

  3. picnixz commented on Oct 12, 2026

    @picnixz
    picnixz
    on Oct 12, 2026
    Member
    More actions

    We would do it for performance critical modules but a general issue is useless until there is something explicit and useful.

  4. ashm-dev commented on Oct 12, 2026

    @ashm-dev
    ashm-dev
    on Oct 12, 2026
    ContributorAuthor
    More actions

    Fair. Ran pyperformance (both standard and PGO) beforehand and got ~1% geomean, so I left it out since it's basically noise. My angle was just cutting LOC and boilerplate, but point taken on the churn. Won't push it.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.