Compress::Snappy(3pm)
π Compress::Snappy β¨
okay so bestie, welcome to Compress::Snappy π β this is the Perl interface to Google's Snappy (de)compressor, and it's living in the User Contributed Perl Documentation section, so you KNOW it's the people's manual. let's get into it π«Ά
πΈ NAME πΈ
Compress::Snappy β the Perl interface to Google's Snappy (de)compressor, periodt. π
β¨ SYNOPSIS β¨
the whole vibe in four lines, no cap:
use Compress::Snappy;
my $dest = compress($source);
my $dest = decompress($source);
like. that's it. that's the module. slay. π
π¦ DESCRIPTION π¦
so Compress::Snappy gives you an interface to Google's Snappy (de)compressor. iconic of it honestly.
and here's the tea π β Snappy is NOT out here trying to squeeze your data into the tiniest possible blob, and it is NOT trying to be compatible with any other compression library. not the goal, not the assignment. what it IS doing is going very high speeds with reasonable compression. so it's the fun fast friend, not the perfectionist.
like, for comparison? next to the fastest mode of zlib, Snappy is an order of magnitude faster for most inputs β but heads up bestie, the compressed files it makes are anywhere from 20% to 100% bigger. speed costs, and the cost is bytes. iykyk π
π FUNCTIONS π
compress
$string = compress($buffer)
smooshes the buffer you hand it and gives you back the resulting string. β¨
the input buffer can be either a scalar or a scalar reference β flexible queen, she contains multitudes. π
decompress
uncompress
$string = decompress($buffer)
un-smooshes the buffer and hands you back the resulting string. the glow-up in reverse. π
same deal as compress β input buffer can be either a scalar or a scalar reference.
π¨ and if something goes wrong β specifically, if the data is corrupted βundefgets returned. no exception drama, just anundef. so CHECK YOUR RETURN VALUE, bestie, please. π
π₯ PERFORMANCE π₯
this distribution ships with a benchmarking script that puts a bunch of other compression modules on CPAN in a head-to-head. main character energy π
these are the results on a MacBook 2GHz Core 2 Duo (64-bit) running Perl 5.14.2:
Compressible data (10 KiB) - compression
----------------------------------------
Compress::LZ4::compress 183794/s 1795 MiB/s 1.152%
Compress::Snappy::compress 122496/s 1196 MiB/s 5.332%
Compress::LZF::compress 44383/s 433 MiB/s 1.865%
Compress::Zlib::compress 2765/s 27 MiB/s 1.201%
Compress::Bzip2::compress 110/s 1 MiB/s 2.070%
Compressible data (10 KiB) - decompression
------------------------------------------
Compress::LZ4::decompress 546133/s 5333 MiB/s
Compress::Snappy::decompress 175363/s 1713 MiB/s
Compress::LZF::decompress 135244/s 1321 MiB/s
Compress::Bzip2::decompress 6352/s 62 MiB/s
Compress::Zlib::uncompress 5440/s 53 MiB/s
Uncompressible data (10 KiB) - compression
------------------------------------------
Compress::LZ4::compress 763738/s 7458 MiB/s 107.463%
Compress::Snappy::compress 552269/s 5393 MiB/s 100.000%
Compress::LZF::compress 532919/s 5204 MiB/s 101.493%
Compress::Bzip2::compress 15424/s 151 MiB/s 185.075%
Compress::Zlib::compress 4325/s 42 MiB/s 105.970%
Uncompressible data (10 KiB) - decompression
--------------------------------------------
Compress::LZF::decompress 2583577/s 25230 MiB/s
Compress::LZ4::decompress 2383127/s 23273 MiB/s
Compress::Snappy::decompress 2068002/s 20195 MiB/s
Compress::Bzip2::decompress 48650/s 475 MiB/s
Compress::Zlib::uncompress 6342/s 62 MiB/s
look at those numbers go π 100.000% on uncompressible data for Snappy compression like?? she said "i'm not inflating this, i'm just built different."
π SEE ALSO π
go read the source material besties, two links, both iconic:
<http://google.github.io/snappy/>
<https://github.com/zeevt/csnappy>
π COPYRIGHT AND LICENSE π
Copyright (c) 2011 gray <gray at cpan.org>, all rights reserved. π«Ά
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
(okay so legally speaking you can do the thing, the Perl thing, you know the one β same terms as Perl itself, and nobody is gonna stop you. π)
π§ AUTHOR π§
gray, <gray at cpan.org> β the icon, the legend, the one who made this whole thing. bow down π
π also hi, just so you know: the header up top saysCompress::Snappy(3pm)in the User Contributed Perl Documentation section, and this whole page got signed off byperl v5.42.3dated2026-08-19. so if you needed receipts, there they are β everything here is fromCompress::Snappy(3pm), no cap. β¨π
π¦ where this page comes from
- ubuntu stonking: libcompress-snappy-perl 0.25+ds-1build2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms