python-performance-optimization

python-performance-optimization is a skill for Claude Code from acaprino/daodan. It costs 53 tokens per session (1,479 once invoked), scanned A, original, MIT.

A Python performance skill that measures CPU time, memory use, line-by-line costs, and input/output waiting before suggesting or applying optimizations.

In plain words
What is it for?
Use it to profile and speed up Python applications, reduce memory consumption, choose between concurrency approaches, and optimize data or database processing.
Why use it?
It helps find the actual bottleneck instead of guessing, including slow functions, excessive memory use, inefficient database queries, and memory leaks.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the python-development plugin — 9 skills, 3 commands, 3 agents shipped together

Good fit Use it to profile and speed up Python applications, reduce memory consumption…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/acaprino/daodan/python-performance-optimization
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add acaprino/daodan --skill python-performance-optimization
Clone the repo
git clone --depth 1 https://github.com/acaprino/daodan

Made for: Claude Code.

Or install python-development, the plugin that ships this one along with the rest of its 9 skills, 3 commands, 3 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-performance-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/acaprino/daodan/python-performance-optimization.svg)](https://agentmods.dev/skills/acaprino/daodan/python-performance-optimization)
Your own site
<a href="https://agentmods.dev/skills/acaprino/daodan/python-performance-optimization"><img src="https://agentmods.dev/badge/skills/acaprino/daodan/python-performance-optimization.svg" alt="Measured on agentmods" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,479 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00053 $0.01479
Opus 5 $0.00026 $0.00740
Sonnet 5 $0.00011 $0.00296
Haiku 4.5 $0.00005 $0.00148

Measured yesterday against content hash d33aaaa58579, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

python-performance-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

exports/claude/plugins/python-development/skills/python-performance-optimization/SKILL.md · 190 lines

How it starts

The opening of the file, as written. The whole thing — 190 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Performance Optimization

Profile, analyze, and optimize Python code for better performance - CPU profiling, memory optimization, and implementation best practices.

When to Invoke

  • User reports slow Python code or asks to speed up execution
  • Profiling or benchmarking Python applications
  • Reducing CPU time, memory consumption, or I/O wait
  • Optimizing database queries or data processing pipelines
  • Debugging memory leaks or excessive memory usage
  • Choosing between parallelization strategies (threading, multiprocessing, async)
  • Evaluating algorithmic vs implementation-level improvements

Core Concepts

Profiling Types

  • CPU Profiling: Identify time-consuming functions (cProfile, py-spy)
  • Memory Profiling: Track memory allocation and leaks (tracemalloc, memory_profiler)
  • Line Profiling: Profile at line-by-line granularity (line_profiler)
  • Call Graph: Visualize function call relationships

Performance Metrics

  • Execution Time: How long operations take
  • Memory Usage: Peak and average memory consumption
  • CPU Utilization: Processor usage patterns
  • I/O Wait: Time spent on I/O operations

Optimization Strategies

  • Algorithmic: Better algorithms and data structures
  • Implementation: More efficient code patterns
  • Parallelization: Multi-threading/processing
  • Caching: Avoid redundant computation
  • Native Extensions: C/Rust for critical paths

Quick Start

import time
import timeit

# Simple timing
start = time.time()
result = sum(range(1000000))
print(f"Execution time: {time.time() - start:.4f} seconds")

# Accurate benchmarking with timeit
execution_time = timeit.timeit("sum(range(1000000))", number=100)
print(f"Average time: {execution_time/100:.6f} seconds")

Profiling Tools Summary

cProfile - CPU Profiling

python -m cProfile -o output.prof script.py
python -m pstats output.prof

line_profiler - Line-by-Line

uv add --dev line-profiler    # or: uv tool install line-profiler
kernprof -l -v script.py

Read the full file on GitHub · 190 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 190 lines · 53 tokens per session scan A d33aaaa58579

Subscribe to this mod's changes

python-performance-optimization is a skill published in the GitHub repository acaprino/daodan (8 stars, last pushed yesterday), licensed MIT. It adds 53 tokens to every session and 1,479 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

Other skills, from other repositories

python-code-quality

Code quality checks, linting, formatting, and type checking commands for the Agent Framework Python codebase. Use this when running checks, fixing lint errors, or troubleshooting CI failures.

microsoft/agent-framework · 40 tokens

plugin-architecture-patterns

Design, implement, or diagnose Xberg plugin traits, typed registries, priority collisions, lifecycle, native extractors, and Alef-generated Python plugin bridges. Load for plugin-system work, not ordinary extractor parsing.

xberg-io/xberg · 49 tokens

test-corpus

The testdocuments submodule is a bucket-fetched fixture corpus that is not committed. This skill covers readtestfixture, missing fixtures, valid A/B controls, and submodule push order. Load before running Rust tests on a fresh clone, setting up an A/B control, adding a fixture-backed test, or diagnosing…

xberg-io/xberg · 72 tokens

idapython

IDA Pro Python scripting for reverse engineering. Use when writing IDAPython scripts, analyzing binaries, working with IDA's API for disassembly, decompilation (Hex-Rays), type systems, cross-references, functions, segments, or any IDA database manipulation. Covers ida modules (50+), idautils iterators, and common…

mrexodia/ida-pro-mcp · 77 tokens

stack-trace-python-probe

Internal helper for meta-stack-trace-investigator. Use when a Python traceback needs Python-specific root-cause checks, pytest reproducer guidance, and defensive patch targets.

opensquilla/opensquilla · 40 tokens

python-debug-execution-911f17

Debug Python script execution failures by capturing full tracebacks and verifying working directory.

HKUDS/OpenSpace · 23 tokens