Skip to content

Expose bzip2 CRC32 like with zlib #153217

Description

@smiRaphi

Feature or enhancement

Proposal:

It's already there for zlib so I don't see a reason why this couldn't be there as well (you could rename it to bz2_crc32 to avoid confusion but I doubt many people will switch their implementation from zlib.crc32 to bzip2.crc32 so I don't think that'd be a big issue)

Example:

import bz2,zlib

data = b'test'
print(f'Hooray, a fast bzip2 crc32 not written in pure python 0x{bz2.crc32(data):08X}')
assert bz2.crc32(data) != zlib.crc32(data)
assert bz2.crc32(data) == bz2.crc32(data)

Also note that my actual use case for this is very non standard and I'm hesitant to open a feature request about adding an option to the bz2.BZ2Decompressor to ignore CRCs as I'm not sure how big the chance of that being accepted is
https://github.com/smiRaphi/UniPyX/blob/9ba67f4dd6f7f88b4bb2433638d9c8ff25231d6c/lib/file.py#L802C1-L829C57

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirpendingThe issue will be closed if no feedback is providedtype-featureA feature request or enhancement

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions