asarchami/dotfiles/performance

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Optimizes Python performance through profiling (cProfile, PyInstrument), memory analysis (memray, tracemalloc), benchmarking (pytest-benchmark), and optimization strategies. Use when analyzing performance bottlenecks or finding memory leaks.

Install

npx vskill@latest install asarchami/dotfiles/performance

SKILL.md

Python Performance Optimization

Profiling Quick Start

bash
# PyInstrument (statistical, readable output)
python -m pyinstrument script.py
# cProfile (detailed, built-in)
python -m cProfile -s cumulative script.py
# Memory profiling
pip install memray
memray run script.py
memray flamegraph memray-*.bin

PyInstrument Usage

python
from pyinstrument import Profiler
profiler = Profiler()
profiler.start()
result = my_function()
profiler.stop()
print(profiler.output_text(unicode=True, color=True))

Memory Analysis

python
import tracemalloc
tracemalloc.start()
snapshot = tracemalloc.take_snapshot()
for stat in snapshot.statistics('lineno')[:10]:
print(stat)

Benchmarking (pytest-benchmark)

python
def test_encode_benchmark(benchmark):
result = benchmark(encode, 37.7749, -122.4194)
assert len(result) == 12
bash
pytest tests/ --benchmark-only
pytest tests/ --benchmark-compare

Common Optimizations

python
# Use set for membership (O(1) vs O(n))
valid = set(items)
if item in valid: ...
# Use deque for queue operations
from collections import deque
queue = deque()
queue.popleft() # O(1) vs list.pop(0) O(n)
# Use generators for large data
def process(items):
for item in items:
yield transform(item)
# Cache expensive computations
from functools import lru_cache
@lru_cache(maxsize=1000)
def expensive(x):
return compute(x)
# String building
result = "".join(str(x) for x in items)

Optimization Checklist

Before Optimizing:
- [ ] Confirm there's a real problem
- [ ] Profile to find actual bottleneck
- [ ] Establish baseline measurements
Process:
- [ ] Algorithm improvements first
- [ ] Then data structures
- [ ] Then implementation details
- [ ] Measure after each change
After:
- [ ] Add benchmarks to prevent regression
- [ ] Verify correctness unchanged
- [ ] Document why optimization needed

Cross-References

  • python-testing — benchmark tests
  • python-code-quality — data structure choices

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/asarchami/dotfiles/performance/badge)](https://verified-skill.com/skills/asarchami/dotfiles/performance)

Something wrong with this skill or its page? Tell us.