Skip to content

_Py_RefcntAdd doesn't increment ref count stats #127599

Closed
@EdNutting

Description

@EdNutting

Bug report

Bug description:

Hi,

I am unsure if this intentional or not so apologies if this turns out not to be a bug.

The code for _Py_RefcntAdd does not include _Py_INCREF_STAT_INC. This appears to mean the statistics do not track these additions to the reference count, which are increments (although not increments by 1, they are increasing the ref count in a single operation).

static inline void _Py_RefcntAdd(PyObject* op, Py_ssize_t n)

I believe this may be an oversight because this stat should be tracked, and also because the corresponding decrement ref count code does call _Py_DECREF_STAT_INC (e.g.

_Py_DECREF_STAT_INC();
)

I have checked the callers of _Py_RefcntAdd (in listobject.c and tupleobject.c) and they do not separately perform the stats tracking.

Is this an issue or is there a reason this ref count increment is excluded?

Thanks,
Ed

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux, macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions