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

Make somePyMutex functions public #117511

Closed
Closed
@colesbury

Description

@colesbury

Feature or enhancement

Overview

ThePyMutex APIs are currently internal-only inpycore_lock.h. This proposes making the type and two functions public in as part of the general, non-limited API inInclude/cpython/lock.h.

The APIs to be included in the public header are:

typedefstructPyMutex {uint8_tv;}PyMutex;staticinlinevoidPyMutex_Lock(PyMutex*m) { ... }staticinlinevoidPyMutex_Unlock(PyMutex*m) { ... }// (private) slow path for locking the mutexPyAPI_FUNC(void)_PyMutex_LockSlow(PyMutex*m);// (private) slow path for unlocking the mutexPyAPI_FUNC(void)_PyMutex_UnlockSlow(PyMutex*m);

Motivation

  • With the free-threaded build, C API extensions are more likely to require locking for thread-safety
  • ThePyMutex API is easier to use correctly than the existingPyThread_type_lock. ThePyMutex APIs release the GIL before blocking, whereas with thePyThread_type_lock APIs you often want to use atwo step approach to locking to release the GIL before blocking.
  • ThePyMutex API enables a more efficient implementation: it's faster to acquire when the lock is not contended and does not require allocation.

C-API WG issue

cc@ngoldbaum

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