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

Expand pyatomic coverage #108337

Closed
Closed
Labels
3.13bugs and security fixestopic-C-APItype-featureA feature request or enhancement
@colesbury

Description

@colesbury

Feature or enhancement

Implementing PEP 703 requires use of atomic operations on more data types than provided bypycore_atomic.h. Additionally,pycore_atomic.h is only usable fromPy_BUILD_CORE modules; it can't be used in public headers. PEP 703 will require atomic operations inobject.h for Py_INCREF/DECREF, for example.

I propose adding a new header to wrap platform/C11 provided atomic operations:

  • The functions will be exposed in the public C-API but prefixed with an underscore to indicate they are private. They need to be exposed because they will be used by other public inline functions.
  • The functions operate on plain data types (i.e.int instead of_Py_atomic_int). This allows use of atomic operations on existing data types where we don't want to change the types of contained fields (i.e, the fields ofPyTypeObject.) and avoids some issues regarding mixing C and C++.
  • Use ofGCC built-in atomics when available. These are available in GCC 4.8+. They do not require passing-std=gnu11 or-std=c11 to the compiler, which avoids breaking third-party extensions.
  • The memory order is part of the function name instead of an argument. This means there are more function definitions (e.g., both_Py_atomic_load_int and_Py_atomic_load_int_relaxed) but keeps the implementation of each function simpler, particularly for MSVC. This reduces boiler-plate code when stepping through debug builds.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixestopic-C-APItype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp