SnappySwift v1.0.0 - Production Release
A pure Swift implementation of Google's Snappy compression algorithm, optimized for speed and providing excellent compatibility with the C++ reference implementation.
Features
- Fast: Compression at 64-128 MB/s, decompression at 203-261 MB/s
- Excellent compression: 20-21x for highly compressible data, 1.5-3x for text
- 100% C++ compatible: Produces output compatible with Google's reference implementation (tested against v1.2.2)
- Zero dependencies: Pure Swift, no external libraries
- Well tested: 90 comprehensive tests including C++ roundtrip validation
- Cross-platform: macOS, iOS, watchOS, tvOS
Installation
Swift Package Manager
Add to your Package.swift:
```swift
dependencies: [
.package(url: "https://github.com/codelynx/snappy-swift.git", from: "1.0.0")
]
```
Quick Start
```swift
import SnappySwift
import Foundation
// Compress data
let original = "Hello, World! This is a test of Snappy compression.".data(using: .utf8)!
let compressed = try original.snappyCompressed()
// Decompress data
let decompressed = try compressed.snappyDecompressed()
assert(decompressed == original)
```
Performance
Measured on Apple Silicon (M1/M2):
- Compression: 64-128 MB/s
- Decompression: 203-261 MB/s
- Compression ratios: 1.5-21x depending on data
Compatibility
- Format: Snappy 1.x format specification
- Tested against: Google C++ Snappy v1.2.2
- Interoperability: 100% compatible with all Snappy 1.x implementations
Documentation
Full documentation available in the README.
License
BSD 3-Clause License - Same as Google Snappy