Python performance

From athola/claude-night-market · View interactive version

Python performance is an AI agent skill from the GitHub repository athola/claude-night-market. Profiles Python code for performance bottlenecks and memory issues. Use when Python code is slow or when profiling for optimization before a release.

How to use this skill

Skill file

Python Performance Optimization

Profiling and optimization patterns for Python code.

Quick Start

# Basic timing
import timeit

time = timeit.timeit("sum(range(1000000))", number=100)
print(f"Average: {time / 100:.6f}s")

Verification: Run the command with --help flag to verify availability.

When To Use

When NOT To Use

instead

instead

Modules

This skill is organized into focused modules for progressive loading:

[profiling-tools](modules/profiling-tools.md)

CPU profiling with cProfile, line profiling, memory profiling, and production profiling with py-spy. Essential for identifying where your code spends time and memory.

[optimization-patterns](modules/optimization-patterns.md)

Eleven proven optimization patterns including list comprehensions, generators, caching, string concatenation, data structures, NumPy, multiprocessing, database operations, and loop transformations (what works in Python vs the compiler).

[memory-management](modules/memory-management.md)

Memory optimization techniques including leak tracking with tracemalloc and weak references for caches. Depends on profiling-tools.

[benchmarking-tools](modules/benchmarking-tools.md)

Benchmarking tools including custom decorators and pytest-benchmark for verifying performance improvements.

[best-practices](modules/best-practices.md)

Best practices, common pitfalls, and exit criteria for performance optimization work. Synthesizes guidance from profiling-tools and optimization-patterns.

Exit Criteria

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.