SWCompression
SWCompression copied to clipboard
ZSTD and LZ4 compression support
I’m wondering if it’ll be possible to add the LZ4 and ZStandard compression algorithms to this library in the future. Personally I would find it useful, as both have outstanding decompression times, and Zstd has a great compression ratio.
Well, this is a good question. General answer: yes, it is possible to add these algorithms at some point in the future (disregarding any unforeseen implementation difficulties which may prevent doing so). I also have some additional thoughts about each of these two algorithms:
-
ZSTD. I did consider some time ago implementing Zstandard, but I found that there was an existing Swift library with an implementation of ZSTD, so I wasn't sure if there was any point in reimplementing it here, in SWCompression. I haven't looked into it thoroughly so I don't know if that library was a native Swift implementation or just a wrapper over the reference implementation. If it is the latter then there is still some potential value in implementing it in pure Swift, since this is the stated goal of SWCompression after all. I also have no idea what is the current status of that library, and, to be fair, I don't even remember its name.
-
LZ4. Honestly, I've never thought about implementing it, since I don't know if/where it is even used (nowadays or in the past). How would you use it personally?
Regarding the first point, if the library you are referencing is this, it is just a wrapper around preexisting Zstandard code rather than a pure Swift implementation.
Regarding the second point, LZ4 shines in decompression speeds.
The use-case for lz4 is the need for extremely quick decompression of rather large files. While LZ4 would be great to have, I wouldn't personally find as much use in it as I would Zstandard. It is a relatively niche compression algorithm with a very specific use-case: nearly unnoticeable decompression times for large files.
To the point of personal use at the moment: I'm a developer for Sileo where we use SWCompression thanks to its pure Swift implementation of various compression algorithms and was hoping to implement ZSTD support, but noticed it was missing from this framework.
LZ4 has been implemented in 4.7.0.
Thanks for this wonderful package – I just wanted to drop in to +1 the request for ZSTD