Visitar URL original
Export `zlib.{adler,crc}32_combine` · Issue #134635 · python/cpython · GitHub
Skip to content

Export zlib.{adler,crc}32_combine #134635

Description

@thatch

Feature or enhancement

Proposal:

This is already provided by zlib, and is useful for computing a crc32 in multiple chunks (not linearly).

What I currently do is use ctypes, but that doesn't work on all environments (like Windows). I don't think we'll need a pure python fallback, just a wrapper of what's in zlib, equivalent of https://github.com/fastzip/fastzip/blob/9019107a6732fab9004e625b075faab96f29265a/fastzip/_crc32_combine.py#L63-L67

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. picnixz commented on May 24, 2025

    @picnixz
    Member

    cc @emmatyping (or is zstd not supporting this one? I don't know if you now want to take care of compression issues as well in general)

  2. emmatyping commented on May 24, 2025

    @emmatyping
    Member

    @picnixz this is zlib related, not zstandard, but I am hoping to take care of more compression issues going forward!

  3. emmatyping commented on May 24, 2025

    @emmatyping
    Member

    I think this request is reasonable, we probably would want to also add adler32_combine for completeness/symmetry.

    I don't think we should add crc32_combine_gen/crc32_combine_op without additional motivation.

  4. picnixz commented on May 24, 2025

    @picnixz
    Member

    this is zlib related

    Yeah, I actually misread the issue first :')

    I am hoping to take care of more compression issues going forward!

    Great to hear!

    adler32_combine

    Yes, sure. Note that we could also think about whether to add binascii.crc32_combine as well (we have a minimal support for CRC32 even without zlib in binascii but I don't know if it would also make sense to expose crc32_combine in this case). I wouldn't recommend it as a first iteration (and we anyway don't have binascii.adler32)

  5. emmatyping commented on May 24, 2025

    @emmatyping
    Member

    I should note that if one is merely iterating over chunks of data, using the value argument to zlib.crc32 (i.e. setting an initial checksum) should work to compute a running checksum.

    However, looking at the fastzip code, they are concurrently calculating the checksums and assembling them afterwards, so they cannot chain calls to zlib.crc32.

  6. self-assigned this
    on May 25, 2025
  7. picnixz commented on May 25, 2025

    @picnixz
    Member

    Actually, there was #82868 and #17048 for adler32_combine but it was not tested. I'll close the older issue and will add both as part of this specific issue.

  8. changed the title [-]Expose crc32_combine from zlib[/-] [+]Export `zlib.{adler,crc}32_combine`[/+] on May 25, 2025
  9. added a commit that references this issue on May 27, 2025
  10. added a commit that references this issue on Jul 12, 2025
  11. added a commit that references this issue on Aug 4, 2025
  12. added a commit that references this issue on Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions