python-memory-profiling
Python memory profiling
Use this skill when Claude needs to explain, reproduce, or investigate memory growth in this repository's Python example. The target is python/program.py, a CPython 3.11.5 program that downloads a Wikipedia page, writes a temporary copy, parses it with BeautifulSoup, and counts words. Its network response and import/cache state can vary, so compare runs made with the same interpreter, dependencies, input/network conditions, and workload.
Prepare a reproducible run
The repository pins Python 3.11.5 in python/.python-version and the profiling dependencies in python/requirements.txt (guppy3==3.1.4.post1, memray==1.11.0, psutil==5.9.8, and filprofiler==2023.3.1). The README setup is:
cd python
pyenv install "$(cat .python-version)"
pyenv local
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Run from python/, not the repository root: the runner scripts import program as a local module. The program performs a live HTTP request, so a failed request is an input/environment failure rather than a profiler result. Do not treat one run's absolute byte counts as a benchmark; repeat the same command when comparing a change.