OpenParable
Skip to content
← Back to skills

Pyspy

Testing & Quality
pyspy

Pyspy is an Agent Skill for testing & quality published in the scverse/spatialdata repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Profile the execution time of a Python script using py-spy and visualize the result with speedscope. Use when the user wants to benchmark performance, find slow code paths, or profile CPU time.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/scverse/spatialdata/blob/HEAD/.claude/skills/pyspy/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/pyspy, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Steps

  1. Ask the user which script to profile (full or relative path).

  2. Run py-spy to record the profile. The output is always written to profile.speedscope.json in the current directory.

    Linux (no sudo needed):

    pixi run -e profiling pyspy script.py
    

    macOS (sudo required — py-spy needs to attach to the process):

    sudo pixi run -e profiling pyspy script.py
    

    If sudo fails to find the pixi environment, use absolute paths:

    sudo /path/to/.pixi/envs/profiling/bin/py-spy record --gil \
      -o profile.speedscope.json --format speedscope \
      -- /path/to/.pixi/envs/profiling/bin/python script.py
    
  3. Open the result in speedscope:

    pixi run -e profiling speedscope
    

    This opens profile.speedscope.json in the browser via the local speedscope CLI.

Notes

  • If the speedscope view is blank, switch threads using the thread selector in the top-right corner.
  • To save a profile before overwriting: cp profile.speedscope.json profile-before.speedscope.json
  • --gil records only time when the GIL is held (Python-level CPU time). Drop it to include C extension time.
  • speedscope must be installed globally: npm install -g speedscope