feat: api port#3
Merged
Merged
Conversation
THIRD_PARTY.md credits farhaanaliii/zlib-rs-python as the upstream the bindings adapt from, with the 16 deviations we correct vs CPython's spec at 5775aa8e. tests/test_adler32.py vendors ChecksumTestCase adler32-only methods (lines 85-93) verbatim with provenance comments.
VersionTestCase, ExceptionTestCase, TestModule, and the rest of CompressObjectTestCase / DecompressObjectTestCase missing from the earlier slices — 16 in-scope tests + test_wbits as xfail. Adjusts error mapping (compress/level → zlib.error, compressobj/wbits → ValueError), makes Decompress.decompress's max_length keyword-OK, and adds __version__ deprecation warning per CPython 3.16 spec.
Thin wrappers over zlib-rs 0.6.3's public combine helpers; i64→u64 cast mirrors C zlib's z_off_t. Vendor CPython's ChecksumCombineMixin + CRC32CombineTestCase + Adler32CombineTestCase verbatim. Also bump abi3 floor to py311 and refresh the cargo-vendor FOD hash (both were already in the working tree).
All callers replaced with real implementations in earlier commits.
Underscore-private decompressor stdlib gzip / streaming readers depend on. Parallel state machine to Decompress: internal input buffer (no unconsumed_tail), max_length < 0 sentinel for unlimited, EOFError on any decompress() after eof. Reuses the NeedDict-on-demand zdict pattern from Decompress. Same gzip-streaming restriction as decompressobj — documented as deviation 17. Vendor ZlibDecompressorTest from cpython@5775aa8e; skip 4G/refleak tests that need CPython's bigmem/refcount harnesses.
decompress() bufsize was usize, so sys.maxsize+1 parsed fine then panicked in Vec::resize. Switch to isize with an explicit negative guard; isize overflow at parse time raises OverflowError, matching CPython's "int too large" message. Vendor test_overflow and test_disallow_instantiation (cpython_only gate dropped — check_disallow_instantiation inlined as assertRaises(TypeError)).
11 bigmem-gated tests from CPython's Lib/test/test_zlib.py (ChecksumBigBufferTestCase, CompressTestCase, CompressObjectTestCase) preserved verbatim and grouped in test_bigmem.py. All skipped because they depend on CPython's test.support.bigmemtest decorator — re-enable by wiring that in. This closes the audit: every CPython test_zlib.py method is now either vendored, vendored-as-xfail (engine divergences), or vendored-as-skip (bigmem/refcount harness).
GitHub's windows-latest runner ships only x64 pythons in hostedtoolcache, so maturin --find-interpreter --target i686 skips all of them and the build fails with "Could not find any interpreters". setup-python@v6 with architecture: x86 plants an interpreter but maturin-action doesn't pick it up. Comment out until we figure out how to provision a 32-bit interpreter the action will find.
Adapted only by rebinding zlib_rs → zlib_py. Methodology, sizes, levels, and iteration counts are upstream's. Sample run on aarch64-darwin: decompress 4-6x faster than CPython, adler32 ~10x, streaming compress 4-5x. crc32 ~3x slower for >=64KB because CPython uses Intel CRC32 intrinsics that zlib-rs doesn't hit on this target. Compression ratios match stdlib byte-for-byte at L9 and diverge at L1/L6 (already documented as ByteParityWithStdlib xfails).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds: