Comparison of serial and parallel implementations for processing large text corpora in Python.
Small, runnable examples covering:
- serial processing
- multiprocessing Pool
- thread-based parallelism
- streaming processing
src/processors.py— implementationssrc/utils.py— helperssrc/bench.py— CLI benchmark harnesstools/generate_corpus.py— generate sample large text filestests/test_processors.py— unit tests
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtRun tests:
pytest -qGenerate a sample corpus (10k lines):
python tools/generate_corpus.py --lines 10000 sample_corpus/large.txtRun a benchmark:
python -m src.bench --file sample_corpus/large.txt --method multiprocessing --workers 4 --limit 10000See src/bench.py --help for all options.