Pyspy

From scverse/spatialdata · View interactive version

Pyspy is an AI agent skill from the GitHub repository scverse/spatialdata. 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.

How to use this skill

Skill file

Steps

  1. Ask the user which script to profile (full or relative path).
  1. Run py-spy to record the profile. The output is always written to profile.speedscope.json in the current directory.

Linux (no sudo needed):

```bash

pixi run -e profiling pyspy script.py

```

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

```bash

sudo pixi run -e profiling pyspy script.py

```

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

```bash

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

```

  1. Open the result in speedscope:

```bash

pixi run -e profiling speedscope

```

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

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.