gh-154707: Replace `PyThread_type_lock` with `PyMutex` in `bufferedio.c` by ByteFlowing1337 · Pull Request #154708 · python/cpython · GitHub
Skip to content

gh-154707: Replace PyThread_type_lock with PyMutex in bufferedio.c - #154708

Closed
ByteFlowing1337 wants to merge 3 commits into
python:mainfrom
ByteFlowing1337:mutex-bufferedio
Closed

gh-154707: Replace PyThread_type_lock with PyMutex in bufferedio.c#154708
ByteFlowing1337 wants to merge 3 commits into
python:mainfrom
ByteFlowing1337:mutex-bufferedio

Conversation

@ByteFlowing1337

@ByteFlowing1337 ByteFlowing1337 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyThread_type_lock is a PyMutex under the hood, so we don't have to make changes like this.

@bedevere-app

bedevere-app Bot commented Jul 27, 2026

Copy link
Copy Markdown

@ByteFlowing1337

Copy link
Copy Markdown
Contributor Author

I think we can still gain some small performance improvements by replacing the legacy APIs, even after #134745?

For example PyThread_allocate_lock calls PyMem_RawMalloc, which may fail and could potentially trigger a slow syscall. Using PyMutex is simpler.

There were also some merged PRs making similar refactors: #150453, #140555, #140711.

@ZeroIntensity

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants