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_TYPE() opaque in limited C API 3.14 #120600

Closed
@vstinner

Description

@vstinner

In the limited C API 3.14 and newer, I propose to change Py_TYPE() and Py_SET_TYPE() implementation to opaque function calls to hide implementation details. I made a similar change for Py_REFCNT() and Py_SET_REFCNT() in Python 3.12.

The problem is that with Free Threading (PEP 703), the implementation of these functions become less trivial than just getting/setting an object member:

staticinlinePyTypeObject*Py_TYPE(PyObject*ob) {return (PyTypeObject*)_Py_atomic_load_ptr_relaxed(&ob->ob_type);}staticinlinevoidPy_SET_TYPE(PyObject*ob,PyTypeObject*type) {_Py_atomic_store_ptr(&ob->ob_type,type);}

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

cc@colesbury@Fidget-Spinner

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