← 输入框|github.com|刷新
Skip to content

The times of calling Py_INCREF/Py_DECREF in extensions are ignored on windows #162828

Backlog

Description

@Locked-chess-official

Bug report

On windows when enable --pystats, the python will only add the macro Py_STATS on itself compiling. This macro will enable Py_INCREF/Py_DECREF calling times counting. However, for the extensions, this macro is not defined by default so it is unable to be counted when calling these functions.

The conditions are:

  • On windows.
  • Full capi (no Py_LIMITED_API defined)
  • Use the macro Py_(X)INCREF and Py_(X)DECREF

When test 10 million times for calling Py_INCREF and Py_DECREF in extensions the counts are:

api func count
Full api Py_INCREF/Py_DECREF 3/4
Full api Py_IncRef/Py_DecRef 10,000,003/10,000,004
Limited api Py_INCREF/Py_DECREF 10,000,003/10,000,004
Limited api Py_IncRef/Py_DecRef 10,000,003/10,000,004

According to discussion, I think that this question can only be fixed if the pyconfig.h is generated dynamically. This is one of the feature that disabled on windows.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Activity

  1. added
    type-bug
    on Nov 29, 2026
  2. added
    build
    on Nov 29, 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

    OS-windowsbuildtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions