GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — Return `b""` from `Compress.flush()` for a repeated sync or full flush, as zlib does by ptweezy · Pull Request #330 · pycompression/python-isal Conversation
Contributor
A With this PR,
One difference from zlib remains. For a full, a sync and a full flush with nothing in between, zlib writes an empty block on the third call, and this PR returns I measured with pyperf in Docker on Linux, as the mean of 2 runs on Python 3.11 and 3.14:
One write followed by 100 The output changes only for back-to-back flushes, and the stream stays valid. The new tests cover repeated flushes at every level for raw, zlib and gzip streams, a flush before any data, a full flush after a sync flush, Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsA sync or full flush with nothing compressed since the previous flush made ISA-L write an empty block: 6 bytes at levels 1 to 3, and 117 bytes at level 0, where each block starts with a Huffman table. Each such flush also allocated a 16 KiB output buffer and called isal_deflate. zlib returns b"" in this case. Compress objects now remember the mode of their last flush. A sync flush after a sync or full flush, and a full flush after a full flush, return b"" when no compress() call came in between. A full flush after a sync flush still writes a block, because it resets the history. compress() forgets the mode even for empty data, as deflate() does in zlib, so compress(b"") + flush(Z_SYNC_FLUSH) still ends in 00 00 ff ff, which permessage-deflate needs for empty messages. Z_FINISH forgets it too, so flushes after finishing behave as before. pyperf timeit on Linux, Python 3.11 / 3.14, mean of 2 runs: - repeated flush(Z_SYNC_FLUSH), level 2: 1.49 / 1.38 µs -> 47 / 51 ns - repeated flush(Z_SYNC_FLUSH), level 0: 160 / 162 ns -> 46 / 50 ns - repeated IGzipFile.flush(): 1.63 / 1.66 µs -> 229 / 323 ns One write followed by 100 IGzipFile.flush() calls now gives 29 instead of 623 bytes at levels 1 to 3 (gzip gives 30), and 253 instead of 11836 bytes at level 0. A flush after new data costs 8 more instructions, which is within timing noise. The output changes only for back-to-back flushes, and the stream stays valid.
ptweezy
force-pushed
the
redundant-sync-flush
branch
from
8457fec to
1e8b2a4
Compare
This branch has not been deployedNo deployments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully 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. | ||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |