|
27 | 27 | import os
|
28 | 28 | import sys
|
29 | 29 |
|
30 |
| -import _compression |
31 |
| - |
32 | 30 | from . import isal_zlib
|
33 | 31 |
|
34 | 32 | __all__ = ["IGzipFile", "open", "compress", "decompress", "BadGzipFile"]
|
|
37 | 35 | _COMPRESS_LEVEL_TRADEOFF = isal_zlib.ISAL_DEFAULT_COMPRESSION
|
38 | 36 | _COMPRESS_LEVEL_BEST = isal_zlib.ISAL_BEST_COMPRESSION
|
39 | 37 |
|
40 |
| -BUFFER_SIZE = _compression.BUFFER_SIZE |
41 |
| - |
42 | 38 | try:
|
43 | 39 | BadGzipFile = gzip.BadGzipFile
|
44 | 40 | except AttributeError: # Versions lower than 3.8 do not have BadGzipFile
|
@@ -278,6 +274,12 @@ def main():
|
278 | 274 | help="Decompress the file instead of compressing.")
|
279 | 275 | parser.add_argument("-c", "--stdout", action="store_true",
|
280 | 276 | help="write on standard output")
|
| 277 | + # -b flag not taken by either gzip or igzip. Hidden attribute. Above 32K |
| 278 | + # diminishing returns hit. _compression.BUFFER_SIZE = 8k. But 32K is about |
| 279 | + # ~6% faster. |
| 280 | + parser.add_argument("-b", "--buffer-size", |
| 281 | + default=32 * 1024, type=int, |
| 282 | + help=argparse.SUPPRESS) |
281 | 283 | args = parser.parse_args()
|
282 | 284 |
|
283 | 285 | compresslevel = args.compresslevel or _COMPRESS_LEVEL_TRADEOFF
|
@@ -310,7 +312,7 @@ def main():
|
310 | 312 |
|
311 | 313 | try:
|
312 | 314 | while True:
|
313 |
| - block = in_file.read(BUFFER_SIZE) |
| 315 | + block = in_file.read(args.buffer_size) |
314 | 316 | if block == b"":
|
315 | 317 | break
|
316 | 318 | out_file.write(block)
|
|
0 commit comments