https://github.com/orisano/golzma
https://github.com/orisano/golzma
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/orisano/golzma
- Owner: orisano
- License: mit
- Created: 2026-05-15T17:17:07.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-16T07:57:46.000Z (2 months ago)
- Last Synced: 2026-05-16T09:50:44.095Z (2 months ago)
- Language: Python
- Size: 73.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# golzma
Pure Go LZMA/LZMA2 decoder with assembly acceleration on ARM64 and AMD64.
## Install
```
go get github.com/orisano/golzma
```
## Usage
### LZMA (.lzma)
```go
import "github.com/orisano/golzma"
r, err := golzma.NewReader(compressedReader)
// read decompressed data from r
```
### LZMA2
```go
r := golzma.NewLZMA2Reader(compressedReader, dictProp)
// read decompressed data from r
```
## Benchmark
The `bench/` directory contains benchmarks comparing the Go decoder against the 7z C implementation.
### Go-only benchmarks
Requires the `lzma` command for generating test data.
```
go test -bench=. ./bench/
```
### C implementation benchmarks
Requires the LZMA SDK C source in `./tmp/lzma/` (from the [LZMA SDK](https://7-zip.org/sdk.html)).
```
go test -tags clzma -bench=. ./bench/
```
### C implementation with assembly benchmarks
Additionally requires building the platform-specific assembly library into `/tmp/libLzmaDecOpt.a`.
For ARM64, build from `tmp/lzma/Asm/arm64/LzmaDecOpt.S`. For AMD64, use [asmc](https://github.com/nidud/asmc) to assemble `tmp/lzma/Asm/x86/LzmaDecOpt.asm`:
```
asmc64 -c -elf64 -DABI_LINUX -Fo/tmp/LzmaDecOpt.o tmp/lzma/Asm/x86/LzmaDecOpt.asm
ar rcs /tmp/libLzmaDecOpt.a /tmp/LzmaDecOpt.o
go test -tags clzma -bench=. ./bench/
```
## Acknowledgements
The assembly generators (`goasm_arm64.py`, `goasm_amd64.py`) are inspired by [s_xbyak](https://github.com/herumi/s_xbyak) by @herumi.
The LZMA decode loop is ported from [LZMA SDK](https://7-zip.org/sdk.html) by Igor Pavlov (public domain).
## License
MIT