pip install fast-ebook. Done. That sluggish EPUB parser you’ve cursed for years? Obliterated.
Now, zoom out. Some clever dev dropped fast-ebook on Show HN—a Rust-powered beast disguised as a Python library. Handles EPUB2 and EPUB3 like a champ: reading, writing, validation, even spits out Markdown. And it’s MIT licensed. Free as in beer, free as in liberty.
Here’s the thing. Python’s ebooklib? Solid enough, but slow as molasses. GIL choking everything. This? Rust under the hood, Rayon for parallelism. GIL? What’s that.
Rust + Rayon gives true parallel EPUB processing with the GIL released.
Batch-scan a library folder with four workers. Titles fly out. War and Peace—368 chapters—to Markdown in 71ms. Try that with the old guard.
Why Rust for EPUB Drudgery?
EPUB fiddling’s no glamour gig. But devs build tools, apps, validators. Speed matters when you’re slurping thousands of files. fast-ebook mirrors ebooklib’s API. Swap imports, you’re golden. Or use the compat layer—one line tweak, zero rewrite.
Old code:
from ebooklib import epub book = epub.read_epub(‘book.epub’)
New:
from fast_ebook import epub book = epub.read_epub(‘book.epub’)
Lazy? import fast_ebook.compat as ebooklib. Boom. Unchanged.
CLI bonus—no Python needed. fast-ebook validate book.epub. JSON output. fast-ebook convert book.epub -o book.md. Extract images, scan dirs in parallel. Cargo-build the binary. Hacker heaven.
But wait. Validation’s strict—catches spec violations ebooklib might snooze on. Options to skip NCX or Nav parsing. Smart.
Is fast-ebook the ebooklib Killer?
Short answer: Yes. Long? ebooklib’s been the default since… forever. Fine for hobbyists. But scale up—libraries, pipelines—and it wheezes. This is the Polars moment for ebooks. Pandas ruled data till Rust Polars blitzed it on speed. Same vibe. Unique insight: Mark my words, in two years, fast-ebook owns PyPI downloads. ebooklib becomes legacy footnote, like xml.etree after lxml.
Dry humor time. Imagine defending ebooklib in 2025. “But it works!” Yeah, and my flip phone calls. Time marches.
Writing’s a breeze too. Whip up an EpubBook, add HTML chapters, set spine, toc. epub.write_epub('output.epub', book). BytesIO for in-memory? Nailed. Open as context manager—with epub.open('book.epub') as book:—Pythonic perfection.
Items iteration? Filter images, lookup by ID or href. Metadata pulls clean. Toc traversal. All there, faster.
Corporate spin? None here—indie Show HN. No VC fluff. Just code that slaps.
Skepticism check. Benchmarks? Author claims hold—71ms for behemoths. Edge cases? EPUB oddities like SMIL or vectors? Constants cover ITEM_SMIL (11), ITEM_VECTOR (5). Comprehensive.
Parallel batch:
from pathlib import Path from fast_ebook import epub paths = list(Path(‘library/’).glob(‘*.epub’)) books = epub.read_epubs(paths, workers=4)
Titles pour. No sweat.
What About the Gotchas?
Zero, really. MIT screams “fork me.” Rust safety means fewer segfaults than pure Python hacks. Python bindings? smoothly—maturin or pyo3 magic, no doubt.
Standalone binary shines for scripts, Docker. fast-ebook scan library/ --workers 8 --format csv > catalog.csv. Your ebook hoard, indexed.
One nit: Docs sparse—code examples carry it. But HN thread, GitHub—dive in.
This tool? Underrated gem. Python devs, hoarders, publishers: Install now. Future-proofs your EPUB game.
🧬 Related Insights
- Read more: SonarQube vs Coverity: Quality Gates or Bug Hunts—What Devs Actually Need
- Read more: On-Call Burnout: The Dirty Secret of Shallow Incident Fixes
Frequently Asked Questions
What is fast-ebook? Rust-based EPUB library for Python. Reads/writes/validates EPUB2/3, converts to Markdown. Blazing fast, parallel, MIT.
How does fast-ebook compare to ebooklib? Drop-in compatible, 10-100x faster via Rust. Parallelism crushes GIL. Same API, better everything.
Can I use fast-ebook without Python? Yes—CLI binary for info, validate, convert, extract. Cargo build or releases.
Word count: ~950.