Uh oh!
There was an error while loading. Please reload this page.
gh-91349: Expose the crc32 function from the lzma library - #131721
gh-91349: Expose the crc32 function from the lzma library#131721morotti wants to merge 1 commit into
Conversation
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.
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.
1b298bd to
ad43096Comparemorotti
commented
Apr 17, 2025
sorry for delay, all the docstring/comments were copy pasted from the zlib function. I guess the old function had an old style that is no longer wanted. for the return type in the docstring, we can settle with "positive integer" https://docs.python.org/3/library/zlib.html#zlib.crc32 |
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.
morotti
commented
Apr 17, 2025
@AA-Turner , I merged all your suggestions. for the versionadded: next, I thought changes on main would ship in 3.14? I am too late for 3.14 release? |
AA-Turner
commented
Apr 17, 2025
'next' is updated by the Release Manager for each version, it's a convenience tool that we use internally. We can still get this in for 3.14, yes. A |
morotti
commented
Apr 17, 2025
regarding performance, don't mind that for now, I will come back later. in principle
liblzma had code to start using hardware crc instructions soon ... and I see they just made a new stable release few days ago https://github.com/tukaani-project/xz/releases |
morotti
commented
Apr 17, 2025
it appears the |
AA-Turner
commented
Apr 17, 2025
I'll re-run it. |
morotti
commented
Apr 17, 2025
build passed, ready to merge |
AA-Turner
commented
Apr 18, 2025
Do you want to include your |
morotti
commented
Apr 18, 2025
Please don't mind the email. |
morotti
commented
May 12, 2025
ping, can this be merged? |
61094d8 to
0603528Comparemorotti
commented
Jun 25, 2025
@merwok@AA-Turner are you able to review? I've rebased on main and redid the chance, since it's been 3 months and main had changed. |
morotti
commented
Jun 27, 2025
@gpshead you've replied multiple times to my questions on improving compression code with "PR welcome". maybe you would be interested in reviewing this PR? |
This PR is stale because it has been open for 30 days with no activity. |
0603528 to
94cf4c8Comparemerwok
commented
Apr 24, 2026
I’m a little confused by the issue linked from this PR. The issue is about using zlib-ng as the underlying library for our zlib module. This PR exposes a function from lzma. What is the link to zlib-ng or zlib module? |
Hello, (first part) It's pretty simple. There is no downside or issue that can come from exposing this simple function that's been stable for decades. (second part) zlib has been unmaintained for most of the decade, it's not using hardware instructions to calculate the CRC and it's never gonna be updated. It started being replaced by zlib-ng for massive performance improvements, see the linked issue, unfortunately there are plenty of systems/OS that will remain stuck on zlib for a long time. Once the lzma crc function is exposed, this will allow applications to use it instead of the slow zlib crc. |
gpshead
commented
Apr 24, 2026
We do not want to increase our reliance on liblzma due to its license and general trust in the project. It'd be far easier to add our own fast internal crc32 implementation if that is desired at this point. |
I'm sorry but this replies makes no sense whatsoever. How is there any problem with xz-utils license or trust? especially in the context of one CRC function? It's free software and it's the baseline of multiple Linux distributions to distribute Linux packages. Python making its own CRC implementation is not on the table, this would require to write advanced C code with intrinsic/assembly per platform, which is completely outside of the scope of python, where maintainers can't even agree on the signature of one function. It's absurd to claim that the code should be in Python. EDIT: if the concern is not wanting the python stdlib (binascii and co) to use lzma.crc because zlib.crc is more free, I'm happy to just expose the function, and not any make further PRs to the interpreter to use it. |
Sorry, I don't understand this. I have absolutely no stake in this bug, but:
Feel free to reject it on other rationale (as I said, I have no opinion on this) but I don't think these two sound right. If there's something that we need to do more on the xz side, please let me know as well. |
gpshead
commented
Apr 28, 2026
Sorry, a quick search was showing me GPL, looking at the repo its a big mix of things and the strictly liblzma part is not GPL. regardless, my larger point is that we should not depend on a compression library for crc32 - it isn't the primary purpose of the library. we should just ship our own performant functions. |
Hello,
This is a simple PR to expose the crc32 function from the lzma library.
The code and tests are very similar to the crc in binascii and zlib. I don't think it's too controversial.
I came across this while looking at compression libraries for #91349
crc32 is always available from the lzma library (xz-utils/liblzma.so). I think it should be exposed.
there are more hashing functions available (namely crc64) but they need compilation/runtime checks to verify whether they are available.
Regards.
📚 Documentation preview 📚: https://cpython-previews--131721.org.readthedocs.build/