Releases: indygreg/python-zstandard
Releases · indygreg/python-zstandard
0.14.1
0.14.0
Backwards Compatibility Notes
- This will likely be the final version supporting Python 2.7. Future
releases will likely only work on Python 3.5+. See #109 for more
context. - There is a significant possibility that future versions will use
Rust - instead of C - for compiled code. See #110 for more context.
Bug Fixes
- Some internal fields of C structs are now explicitly initialized.
(Possible fix for #105.) - The
make_cffi.pyscript used to build the CFFI bindings now
callsdistutils.sysconfig.customize_compiler()so compiler
customizations (such as honoring theCCenvironment variable)
are performed. Patch by @Arfrever. (#103) - The
make_cffi.pyscript now setsLC_ALL=Cwhen invoking
the preprocessor in an attempt to normalize output to ASCII. (#95)
Changes
- Bundled zstandard library upgraded from 1.4.4 to 1.4.5. See release notes at https://github.com/facebook/zstd/releases/tag/v1.4.5.
setup.pyis now executable.- Python code reformatted with black using 80 character line lengths.
0.13.0
Changes
pytest-xdistpytestextension is now installed so tests can be
run in parallel.- CI now builds
manylinux2010andmanylinux2014binary wheels
instead of a mix ofmanylinux2010andmanylinux1. - Official support for Python 3.8 has been added.
- Bundled zstandard library upgraded from 1.4.3 to 1.4.4.
- Python code has been reformatted with black.
0.12.0
Backwards Compatibility Notes
- Support for Python 3.4 has been dropped since Python 3.4 is no longer
a supported Python version upstream. (But it will likely continue to
work until Python 2.7 support is dropped and we port to Python 3.5+
APIs.)
Bug Fixes
- Fix
ZstdDecompressor.__init__on 64-bit big-endian systems (#91). - Fix memory leak in
ZstdDecompressionReader.seek()(#82).
Changes
- CI transitioned to Azure Pipelines (from AppVeyor and Travis CI).
- Switched to
pytestfor running tests (fromnose). - Bundled zstandard library upgraded from 1.3.8 to 1.4.3.
0.11.0
New Features
- zstd library upgraded from 1.3.6 to 1.3.8.
ZstdCompressor.stream_reader(),ZstdCompressor.stream_writer(),ZstdDecompressor.stream_reader(), andZstdDecompressor.stream_writer()should now completely implement theio.RawIOBaseinterface, allowing them to be used as fully-featured streams. One can combine an instance with say anio.TextIOWrapper,codecs.StreamReader, orcodecs.StreamWriterto transparently convert between binary and textual data or apply encodings to data. A stream reader or writer should interoperate with any Python code that accepts a stream-like object. Please note that some implementation details may change slightly in the future in order to ensure better compatibility with the stream interfaces.ZstdDecompressor.stream_reader()can now read inputs that have multiple zstd frames. Look for future releases to improve support for reading sources with multiple frames.
Backwards Compatibility Notes
ZstdDecompressor.read()now allows reading sizes of-1or0
and defaults to-1, per the documented behavior of
io.RawIOBase.read(). Previously, we required an argument that was
a positive value.- The
readline(),readlines(),__iter__, and__next__methods
ofZstdDecompressionReader()now raiseio.UnsupportedOperation
instead ofNotImplementedError. ZstdDecompressor.stream_reader()now accepts aread_across_frames
argument. The default value will likely be changed in a future release
and consumers are advised to pass the argument to avoid unwanted change
of behavior in the future.setup.pynow always disables the CFFI backend if the installed
CFFI package does not meet the minimum version requirements. Before, it was
possible for the CFFI backend to be generated and a run-time error to
occur.- In the CFFI backend,
CompressionReaderandDecompressionReader
were renamed toZstdCompressionReaderandZstdDecompressionReader,
respectively so naming is identical to the C extension. This should have
no meaningful end-user impact, as instances aren't meant to be
constructed directly. ZstdDecompressor.stream_writer()now accepts awrite_return_read
argument to control whetherwrite()returns the number of bytes
read from the source / written to the decompressor. It defaults to off,
which preserves the existing behavior of returning the number of bytes
emitted from the decompressor. The default will change in a future release
so behavior aligns with the specified behavior ofio.RawIOBase.ZstdDecompressionWriter.__exit__now callsself.close(). This
will result in that stream plus the underlying stream being closed as
well. If this behavior is not desirable, do not use instances as
context managers.ZstdCompressor.stream_writer()now accepts awrite_return_read
argument to control whetherwrite()returns the number of bytes read
from the source / written to the compressor. It defaults to off, which
preserves the existing behavior of returning the number of bytes emitted
from the compressor. The default will change in a future release so
behavior aligns with the specified behavior ofio.RawIOBase.ZstdCompressionWriter.__exit__now callsself.close(). This will
result in that stream plus any underlying stream being closed as well. If
this behavior is not desirable, do not use instances as context managers.ZstdDecompressionWriterno longer requires being used as a context
manager (#57).ZstdCompressionWriterno longer requires being used as a context
manager (#57).- The
overlap_size_logattribute onCompressionParametersinstances
has been deprecated and will be removed in a future release. The
overlap_logattribute should be used instead. - The
overlap_size_logargument toCompressionParametershas been
deprecated and will be removed in a future release. Theoverlap_log
argument should be used instead. - The
ldm_hash_every_logattribute onCompressionParametersinstances
has been deprecated and will be removed in a future release. The
ldm_hash_rate_logattribute should be used instead. - The
ldm_hash_every_logargument toCompressionParametershas been
deprecated and will be removed in a future release. Theldm_hash_rate_log
argument should be used instead. - The
compression_strategyargument toCompressionParametershas been
deprecated and will be removed in a future release. Thestrategy
argument should be used instead. - The
SEARCHLENGTH_MINandSEARCHLENGTH_MAXconstants are deprecated
and will be removed in a future release. UseMINMATCH_MINand
MINMATCH_MAXinstead. - The
zstd_cffimodule has been renamed tozstandard.cffi. As had
been documented in theREADMEfile since the0.9.0release, the
module should not be imported directly at its new location. Instead,
import zstandardto cause an appropriate backend module to be loaded
automatically.
Bug Fixes
- CFFI backend could encounter a failure when sending an empty chunk into
ZstdDecompressionObj.decompress(). The issue has been fixed. - CFFI backend could encounter an error when calling
ZstdDecompressionReader.read()if there was data remaining in an
internal buffer. The issue has been fixed. (#71)
Changes
ZstDecompressionObj.decompress()now properly handles empty inputs in
the CFFI backend.ZstdCompressionReadernow implementsread1()andreadinto1().
These are part of theio.BufferedIOBaseinterface.ZstdCompressionReaderhas gained areadinto(b)method for reading
compressed output into an existing buffer.ZstdCompressionReader.read()now defaults tosize=-1and accepts
read sizes of-1and0. The new behavior aligns with the documented
behavior ofio.RawIOBase.ZstdCompressionReadernow implementsreadall(). Previously, this
method raisedNotImplementedError.ZstdDecompressionReadernow implementsread1()andreadinto1().
These are part of theio.BufferedIOBaseinterface.ZstdDecompressionReader.read()now defaults tosize=-1and accepts
read sizes of-1and0. The new behavior aligns with the documented
behavior ofio.RawIOBase.ZstdDecompressionReader()now implementsreadall(). Previously, this
method raisedNotImplementedError.- The
readline(),readlines(),__iter__, and__next__methods
ofZstdDecompressionReader()now raiseio.UnsupportedOperation
instead ofNotImplementedError. This reflects a decision to never
implement text-based I/O on (de)compressors and keep the low-level API
operating in the binary domain. (#13) README.rstnow documented how to achieve linewise iteration using
anio.TextIOWrapperwith aZstdDecompressionReader.ZstdDecompressionReaderhas gained areadinto(b)method for
reading decompressed output into an existing buffer. This allows chaining
to anio.TextIOWrapperon Python 3 without using anio.BufferedReader.ZstdDecompressor.stream_reader()now accepts aread_across_frames
argument to control behavior when the input data has multiple zstd
frames. WhenFalse(the default for backwards compatibility), a
read()will stop when the end of a zstd frame is encountered. When
True,read()can potentially return data spanning multiple zstd
frames. The default will likely be changed toTruein a future
release.setup.pynow performs CFFI version sniffing and disables the CFFI
backend if CFFI is too old. Previously, we only usedinstall_requires
to enforce the CFFI version and not all build modes would properly enforce
the minimum CFFI version. (#69)- CFFI's
ZstdDecompressionReader.read()now properly handles data
remaining in any internal buffer. Before, repeatedread()could
result in random errors. (#71) - Upgraded various Python packages in CI environment.
- Upgrade to hypothesis 4.5.11.
- In the CFFI backend,
CompressionReaderandDecompressionReader
were renamed toZstdCompressionReaderandZstdDecompressionReader,
respectively. ZstdDecompressor.stream_writer()now accepts awrite_return_read
argument to control whetherwrite()returns the number of bytes read
from the source. It defaults toFalseto preserve backwards
compatibility.ZstdDecompressor.stream_writer()now implements theio.RawIOBase
interface and behaves as a proper stream object.ZstdCompressor.stream_writer()now accepts awrite_return_read
argument to control whetherwrite()returns the number of bytes read
from the source. It defaults toFalseto preserve backwards
compatibility.ZstdCompressionWriternow implements theio.RawIOBaseinterface and
behaves as a proper stream object.close()will now close the stream
and the underlying stream (if possible).__exit__will now call
close(). Methods likewritable()andfileno()are implemented.ZstdDecompressionWriterno longer must be used as a context manager.ZstdCompressionWriterno longer must be used as a context manager.
When not using as a context manager, it is important to call
flush(FRAME_FRAME)or the compression stream won't be properly
terminated and decoders may complain about malformed input.ZstdCompressionWriter.flush()(what is returned from
ZstdCompressor.stream_writer()) now accepts an argument controlling the
flu...
0.10.2
0.10.1
Backwards Compatibility Notes
ZstdCompressor.stream_reader().closedis now a property instead of a
method (#58).ZstdDecompressor.stream_reader().closedis now a property instead of a
method (#58).
Changes
- Stop attempting to package Python 3.6 for Miniconda. The latest version of
Miniconda is using Python 3.7. The Python 3.6 Miniconda packages were a lie
since this were built against Python 3.7. ZstdCompressor.stream_reader()'s andZstdDecompressor.stream_reader()'s
closedattribute is now a read-only property instead of a method. This now
properly matches theIOBaseAPI and allows instances to be used in more
places that acceptIOBaseinstances.
0.10.0
Backwards Compatibility Notes
ZstdDecompressor.stream_reader().read()now consistently requires an
argument in both the C and CFFI backends. Before, the CFFI implementation
would assume a default value of-1, which was later rejected.- The
compress_literalsargument and attribute has been removed from
zstd.ZstdCompressionParametersbecause it was removed by the zstd 1.3.5
API. ZSTD_CCtx_setParametersUsingCCtxParams()is no longer called on every
operation performed againstZstdCompressorinstances. The reason for this
change is that the zstd 1.3.5 API no longer allows this without calling
ZSTD_CCtx_resetParameters()first. But if we called
ZSTD_CCtx_resetParameters()on every operation, we'd have to redo
potentially expensive setup when using dictionaries. We now call
ZSTD_CCtx_reset()on every operation and don't attempt to change
compression parameters.- Objects returned by
ZstdCompressor.stream_reader()no longer need to be
used as a context manager. The context manager interface still exists and its
behavior is unchanged. - Objects returned by
ZstdDecompressor.stream_reader()no longer need to be
used as a context manager. The context manager interface still exists and its
behavior is unchanged.
Bug Fixes
ZstdDecompressor.decompressobj().decompress()should now return all data
from internal buffers in more scenarios. Before, it was possible for data to
remain in internal buffers. This data would be emitted on a subsequent call
todecompress(). The overall output stream would still be valid. But if
callers were expecting input data to exactly map to output data (say the
producer had usedflush(COMPRESSOBJ_FLUSH_BLOCK)and was attempting to
map input chunks to output chunks), then the previous behavior would be
wrong. The new behavior is such that output from
flush(COMPRESSOBJ_FLUSH_BLOCK)fed intodecompressobj().decompress()
should produce all available compressed input.ZstdDecompressor.stream_reader().read()should no longer segfault after
a previous context manager resulted in error (#56).ZstdCompressor.compressobj().flush(COMPRESSOBJ_FLUSH_BLOCK)now returns
all data necessary to flush a block. Before, it was possible for the
flush()to not emit all data necessary to fully represent a block. This
would mean decompressors wouldn't be able to decompress all data that had been
fed into the compressor andflush()ed. (#55).
New Features
- New module constants
BLOCKSIZELOG_MAX,BLOCKSIZE_MAX,
TARGETLENGTH_MAXthat expose constants from libzstd. - New
ZstdCompressor.chunker()API for manually feeding data into a
compressor and emitting chunks of a fixed size. Likecompressobj(), the
API doesn't impose restrictions on the input or output types for the
data streams. Unlikecompressobj(), it ensures output chunks are of a
fixed size. This makes this API useful when the compressed output is being
fed into an I/O layer, where uniform write sizes are useful. ZstdCompressor.stream_reader()no longer needs to be used as a context
manager (#34).ZstdDecompressor.stream_reader()no longer needs to be used as a context
manager (#34).- Bundled zstandard library upgraded from 1.3.4 to 1.3.6.
Changes
zstandard.__version__is now defined (#50).- Upgrade pip, setuptools, wheel, and cibuildwheel packages to latest versions.
- Upgrade various packages used in CI to latest versions. Notably tox (in
order to support Python 3.7). - Use relative paths in setup.py to appease Python 3.7 (#51).
- Added CI for Python 3.7.
0.9.1
0.9.0
Backwards Compatibility Notes
- CFFI 1.11 or newer is now required (previous requirement was 1.8).
- The primary module is now
zstandard. Please change imports ofzstd
andzstd_cffitoimport zstandard. See the README for more. Support
for importing the old names will be dropped in the next release. ZstdCompressor.read_from()andZstdDecompressor.read_from()have
been renamed toread_to_iter().read_from()is aliased to the new
name and will be deleted in a future release.- Support for Python 2.6 has been removed.
- Support for Python 3.3 has been removed.
- The
selectivityargument totrain_dictionary()has been removed, as
the feature disappeared from zstd 1.3. - Support for legacy dictionaries has been removed. Cover dictionaries are now
the default.train_cover_dictionary()has effectively been renamed to
train_dictionary(). - The
allow_emptyargument fromZstdCompressor.compress()has been
deleted and the method now allows empty inputs to be compressed by default. estimate_compression_context_size()has been removed. Use
CompressionParameters.estimated_compression_context_size()instead.get_compression_parameters()has been removed. Use
CompressionParameters.from_level()instead.- The arguments to
CompressionParameters.__init__()have changed. If you
were using positional arguments before, the positions now map to different
arguments. It is recommended to use keyword arguments to construct
CompressionParametersinstances. TARGETLENGTH_MAXconstant has been removed (it disappeared from zstandard
1.3.4).ZstdCompressor.write_to()andZstdDecompressor.write_to()have been
renamed toZstdCompressor.stream_writer()and
ZstdDecompressor.stream_writer(), respectively. The old names are still
aliased, but will be removed in the next major release.- Content sizes are written into frame headers by default
(ZstdCompressor(write_content_size=True)is now the default). CompressionParametershas been renamed toZstdCompressionParameters
for consistency with other types. The old name is an alias and will be removed
in the next major release.
Bug Fixes
- Fixed memory leak in
ZstdCompressor.copy_stream()(#40) (from 0.8.2). - Fixed memory leak in
ZstdDecompressor.copy_stream()(#35) (from 0.8.2). - Fixed memory leak of
ZSTD_DDictinstances in CFFI'sZstdDecompressor.
New Features
- Bundlded zstandard library upgraded from 1.1.3 to 1.3.4. This delivers various
bug fixes and performance improvements. It also gives us access to newer
features. - Support for negative compression levels.
- Support for long distance matching (facilitates compression ratios that approach
LZMA). - Supporting for reading empty zstandard frames (with an embedded content size
of 0). - Support for writing and partial support for reading zstandard frames without a
magic header. - New
stream_reader()API that exposes theio.RawIOBaseinterface (allows
you to.read()from a file-like object). - Several minor features, bug fixes, and performance enhancements.
- Wheels for Linux and macOS are now provided with releases.
Changes
- Functions accepting bytes data now use the buffer protocol and can accept
more types (likememoryviewandbytearray) (#26). - Add #includes so compilation on OS X and BSDs works (#20).
- New
ZstdDecompressor.stream_reader()API to obtain a read-only i/o stream
of decompressed data for a source. - New
ZstdCompressor.stream_reader()API to obtain a read-only i/o stream of
compressed data for a source. - Renamed
ZstdDecompressor.read_from()toZstdDecompressor.read_to_iter().
The old name is still available. - Renamed
ZstdCompressor.read_from()toZstdCompressor.read_to_iter().
read_from()is still available at its old location. - Introduce the
zstandardmodule to import and re-export the C or CFFI
backend as appropriate. Behavior can be controlled via the
PYTHON_ZSTANDARD_IMPORT_POLICYenvironment variable. See README for
usage info. - Vendored version of zstd upgraded to 1.3.4.
- Added module constants
CONTENTSIZE_UNKNOWNandCONTENTSIZE_ERROR. - Add
STRATEGY_BTULTRAcompression strategy constant. - Switch from deprecated
ZSTD_getDecompressedSize()to
ZSTD_getFrameContentSize()replacement. ZstdCompressor.compress()can now compress empty inputs without requiring
special handling.ZstdCompressorandZstdDecompressornow have amemory_size()
method for determining the current memory utilization of the underlying zstd
primitive.train_dictionary()has new arguments and functionality for trying multiple
variations of COVER parameters and selecting the best one.- Added module constants
LDM_MINMATCH_MIN,LDM_MINMATCH_MAX, and
LDM_BUCKETSIZELOG_MAX. - Converted all consumers to the zstandard new advanced API, which uses
ZSTD_compress_generic() CompressionParameters.__init__now accepts several more arguments,
including support for long distance matching.ZstdCompressionDict.__init__now accepts adict_typeargument that
controls how the dictionary should be interpreted. This can be used to
force the use of content-only dictionaries or to require the presence
of the dictionary magic header.ZstdCompressionDict.precompute_compress()can be used to precompute the
compression dictionary so it can efficiently be used with multiple
ZstdCompressorinstances.- Digested dictionaries are now stored in
ZstdCompressionDictinstances,
created automatically on first use, and automatically reused by all
ZstdDecompressorinstances bound to that dictionary. - All meaningful functions now accept keyword arguments.
ZstdDecompressor.decompressobj()now accepts awrite_sizeargument
to control how much work to perform on every decompressor invocation.ZstdCompressor.write_to()now exposes atell(), which exposes the
total number of bytes written so far.ZstdDecompressor.stream_reader()now supportsseek()when moving
forward in the stream.- Removed
TARGETLENGTH_MAXconstant. - Added
frame_header_size(data)function. - Added
frame_content_size(data)function. - Consumers of
ZSTD_decompress*have been switched to the new advanced
decompression API. ZstdCompressorandZstdCompressionParamscan now be constructed with
negative compression levels.ZstdDecompressornow accepts amax_window_sizeargument to limit the
amount of memory required for decompression operations.FORMAT_ZSTD1andFORMAT_ZSTD1_MAGICLESSconstants to be used with
theformatcompression parameter to control whether the frame magic
header is written.ZstdDecompressornow accepts aformatargument to control the
expected frame format.ZstdCompressornow has aframe_progression()method to return
information about the current compression operation.- Error messages in CFFI no longer have
b''literals. - Compiler warnings and underlying overflow issues on 32-bit platforms have been
fixed. - Builds in CI now build with compiler warnings as errors. This should hopefully
fix new compiler warnings from being introduced. - Make
ZstdCompressor(write_content_size=True)and
CompressionParameters(write_content_size=True)the default. CompressionParametershas been renamed toZstdCompressionParameters.