gh-154707: Replace PyThread_type_lock with PyMutex in bufferedio.c - #154708
gh-154707: Replace PyThread_type_lock with PyMutex in bufferedio.c#154708ByteFlowing1337 wants to merge 3 commits into
PyThread_type_lock with PyMutex in bufferedio.c#154708Conversation
ZeroIntensity
left a comment
There was a problem hiding this comment.
PyThread_type_lock is a PyMutex under the hood, so we don't have to make changes like this.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I think we can still gain some small performance improvements by replacing the legacy APIs, even after #134745? For example There were also some merged PRs making similar refactors: #150453, #140555, #140711. |
|
I'd be very surprised if you noticed any speedup by removing a single 1-byte allocation. What actually prompted you to raise this? Were you benchmarking and found an actual slowdown in the In CPython, we often get contributors who want to make any sort of change solely so they can put "Python contributor" on their CV. This problem has gotten even worse now that LLMs can basically make this effortless. (I'm not accusing you of doing this, just to be clear -- I'm just trying to give you the context that makes me unhappy about this.) As such, we like to avoid "code churn", or in other words, we don't like to make changes that don't have an actual effect on behavior, because:
Rant aside, my concern is that this will encourage copycat PRs that do the same thing. Again, contributors should make meaningful contributions, even if all they're after is a line on their resume. We don't really care about the intent; we care about the contribution. That means we shouldn't open the door to contributions like this by setting a precedent. I could approve and merge this, and we'd enjoy maybe a 0.001% speedup, but then I risk 10 more PRs that do the same thing in random files across the codebase, and I can't really turn them down for any good reason (beyond just "I said so", which doesn't reflect well on us as a core team). Those other PRs made it in because they weren't out of the blue; a maintainer noticed it and made the conscious decision to change the code for their own reasons. In particular:
When the context is different, the precedent doesn't work as well. Now, I'm not saying this is a bad change in general. My point is more that this should happen as part of a holistic pass over |
PyMutexin the buffered I/O module #154707