equal
deleted
inserted
replaced
683 opts = opts or {} |
683 opts = opts or {} |
684 # zstd level 3 is almost always significantly faster than zlib |
684 # zstd level 3 is almost always significantly faster than zlib |
685 # while providing no worse compression. It strikes a good balance |
685 # while providing no worse compression. It strikes a good balance |
686 # between speed and compression. |
686 # between speed and compression. |
687 level = opts.get(b'level', 3) |
687 level = opts.get(b'level', 3) |
|
688 # default to single-threaded compression |
|
689 threads = opts.get(b'threads', 0) |
688 |
690 |
689 zstd = self._module |
691 zstd = self._module |
690 z = zstd.ZstdCompressor(level=level).compressobj() |
692 z = zstd.ZstdCompressor(level=level, threads=threads).compressobj() |
691 for chunk in it: |
693 for chunk in it: |
692 data = z.compress(chunk) |
694 data = z.compress(chunk) |
693 if data: |
695 if data: |
694 yield data |
696 yield data |
695 |
697 |