Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[C API] Make Py_REFCNT() opaque in limited C API 3.14 #124127

Closed
@vstinner

Description

@vstinner

In the limited C API 3.14 and newer, I propose to change Py_REFCNT() implementation to an opaque function call to hide implementation details. I made a similar change for Py_INCREF() and Py_DECREF() in Python 3.12.

The problem is that with Free Threading (PEP 703), the implementation of this functions becomes less trivial than just getting the object memberPyObject.ob_refcnt:

staticinlinePy_ssize_t_Py_REFCNT(PyObject*ob) {uint32_tlocal=_Py_atomic_load_uint32_relaxed(&ob->ob_ref_local);if (local==_Py_IMMORTAL_REFCNT_LOCAL) {return_Py_IMMORTAL_REFCNT;    }Py_ssize_tshared=_Py_atomic_load_ssize_relaxed(&ob->ob_ref_shared);return_Py_STATIC_CAST(Py_ssize_t,local)+Py_ARITHMETIC_RIGHT_SHIFT(Py_ssize_t,shared,_Py_REF_SHARED_SHIFT);}

_Py_atomic_load_uint32_relaxed() and_Py_atomic_load_ssize_relaxed() must now be called. But I would prefer to not "leak" such implementation detail into the limited C API.

cc@colesbury@Fidget-Spinner@encukou

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp