GeezerVison is showing github.com — gh-132983: Simplify `_zstd_exec()` by AA-Turner · Pull Request #133775 · python/cpython
Conversation
AA-Turner
commented
May 9, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
cc @Rogdham (can't request review).
Follows on from #133670. Again best reviewed commit-by-commit. We remove around 100 lines of C code overall.
The last commit (6a3a135 (#133775)) only serves to merge two functions and contains no behaviour change, but does increase the diff size.
- Rename type specs to add underscores after 'zstd'
- Replace the
add_type_to_module() function with an ADD_TYPE macro, using PyModule_AddType instead of PyModule_AddObjectRef.
- Remove the unused 'empty_readonly_memoryview', 'str_flush', 'str_read', 'str_readinto', and 'str_write' module state members
- Set the CONTINUE/FLUSH_* constants in Python rather than C. To achieve this, export the three ZSTD_EndDirective enum members from the
_zstd module.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I think it's a nice improvement but usually, C classes are read-only (e.g., _sha2.SHA2Type does not allow setting class variables afterwards; the same holds for lzma.LZMACompressor so it would be better to do the same for the Zstd* types)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
serhiy-storchaka reacted with thumbs up emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to make classes implemented in C immutable.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
AA-Turner and emmatyping reacted with thumbs up emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! These are great refactors.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add Py_TPFLAGS_IMMUTABLETYPE in this PR or in another.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @AA-Turner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
picnixz
picnixz approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|