|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +FastFeedParser is a high-performance Python library for parsing RSS, Atom, RDF, and JSON feeds. ~10x faster than feedparser while maintaining a similar API. Used in production by [Kagi Small Web](https://github.com/kagisearch/smallweb). |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +pip install -e . # Install dependencies |
| 13 | +pytest # Run all tests |
| 14 | +pytest -k "test_name" # Run tests matching pattern |
| 15 | +python benchmark.py # Benchmark against feedparser |
| 16 | +python benchmark.py -s # Benchmark fastfeedparser only |
| 17 | +``` |
| 18 | + |
| 19 | +## Architecture |
| 20 | + |
| 21 | +Single-file parser: `src/fastfeedparser/main.py` |
| 22 | + |
| 23 | +**Entry point:** `parse(source)` - accepts URL or XML/JSON string/bytes |
| 24 | + |
| 25 | +**Feed type detection order:** RSS 2.0 → Atom 1.0 → RDF/RSS 1.0 → JSON Feed |
| 26 | + |
| 27 | +**Internal parsing functions:** |
| 28 | +- `_parse_rss()` - RSS 2.0 with fallback to Atom-style entries |
| 29 | +- `_parse_atom()` - Atom 1.0 |
| 30 | +- `_parse_rdf()` - RDF/RSS 1.0 |
| 31 | +- `_parse_json_feed()` - JSON Feed 1.0/1.1 |
| 32 | + |
| 33 | +**Date parsing cascade:** ISO-8601 → RFC-822 → dateutil → dateparser (slowest, LRU-cached) |
| 34 | + |
| 35 | +**Performance patterns:** |
| 36 | +- lxml with strict parser first, recover parser as fallback |
| 37 | +- Pre-compiled regex (`_RE_*` constants) |
| 38 | +- LRU-cached slow parsers (`_slow_dateutil_parse`, `_slow_dateparser`) |
| 39 | + |
| 40 | +## Testing |
| 41 | + |
| 42 | +Snapshot testing: feed files in `tests/integration/` compared against `.json` expected output. |
| 43 | + |
| 44 | +To add a test case: |
| 45 | +1. Add feed file to `tests/integration/` |
| 46 | +2. Run `pytest` - generates expected `.json` on first run |
| 47 | +3. Verify output, commit both files |
0 commit comments