Agent skill

Python Performance

by caarlos0 in caarlos0/dotfiles

Profile and optimize Python CPU, memory, I/O, concurrency, and numerical performance.

MITAuto-check passedDevelopment

Install Python Performance

skills CLI
$ npx skills add caarlos0/dotfiles --skill python-performance -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install caarlos0/dotfiles python-performance --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/caarlos0/dotfiles.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/python-performance .claude/skills/python-performance && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
python-performance
GitHub stars
220
Token cost
~1.6k tokens
SKILL.md length
794 words
Files
1
Skills in repo
20
Repo updated
First seen
Licence
MIT

At a glance

Profile and optimize Python CPU, memory, I/O, concurrency, and numerical performance.

  • Development work in your project
  • SKILL.md covers Measurement, Data structures and Python…, Memory and GC and Threads, asyncio, and processes, plus 5 more sections
  • Calls python

What it does

Python Performance is an agent skill from caarlos0/dotfiles. Profile and optimize Python CPU, memory, I/O, concurrency, and numerical performance.

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development. It works with Python. The licence is MIT.

When your agent uses it

  • Development work in your project

Example prompts

  • “/python-performance”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 278c761. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Python Performance loads about 1.6k tokens when it runs. Until then it costs about 26 tokens; SKILL.md has 794 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~26
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from caarlos0/dotfiles at commit 278c761, republished under its MIT licence (© caarlos0). 794 words, ~1,555 tokens.

Download SKILL.mdSave it as .claude/skills/python-performance/SKILL.md (or your agent's skills folder).
name
python-performance
description
Profile and optimize Python CPU, memory, I/O, concurrency, and numerical performance.

Python Performance

Name the metric first: wall time, CPU time, allocation count, retained heap, peak RSS, or I/O wait. Pin Python, dependencies, input, and environment; then change one profiled cause.

Measurement

  • Use pyperf for repeatable benchmarks with calibration, worker processes, metadata, and statistical comparison.
  • Use timeit only for small fragments. It disables cyclic GC during timing unless explicitly re-enabled, which can make allocation-heavy code look unlike production.
  • Use cProfile for call counts and cumulative development profiles; use a sampling profiler such as py-spy for lower-overhead process observation.
  • Use tracemalloc for Python-managed allocations. If RSS grows while its traces remain stable, inspect native allocations or fragmentation with Memray or an OS profiler.
  • sys.getsizeof is shallow; it does not measure referenced objects.
  • Use python -X importtime before changing startup imports.

Data structures and Python operations

Choose from access patterns:

NeedPrefer
Membership or deduplicationset or dict, not repeated list scans
Queue operations at both endscollections.deque, not list.pop(0)
Priority queueheapq
Search in maintained sorted databisect
Mutable binary accumulationbytearray, then bytes(buffer)
Many string fragmentscollect fragments and "".join(parts)

These choices change semantics and memory. Do not replace a list when callers need indexing, slicing, or compact iteration.

Generators avoid eager materialization but add iteration overhead and cannot be reused. Built-ins and comprehensions often move work into optimized C loops, but they are not automatically faster for every workload.

lru_cache trades CPU for retained memory and invalidation. On an instance method, cache keys retain self; avoid it when instances must be collected. @dataclass(slots=True) or __slots__ can reduce memory for many instances but affects dynamic attributes, inheritance, weak references, serialization, and framework integration.

Memory and GC

CPython uses reference counting plus cyclic GC. Distinguish:

  • growing Python allocation traces;
  • retained reachable objects;
  • native allocations;
  • allocator fragmentation;
  • peak RSS;
  • allocation churn that increases CPU without retaining memory.

High RSS alone is not a leak. Tune GC thresholds, call gc.freeze(), or change allocators only after pause, allocation, or copy-on-write measurements identify the collector or allocator as the cause. GC defaults differ by Python version and free-threaded build.

Threads, asyncio, and processes

  • Threads overlap many blocking I/O operations because those calls release the GIL. Pure-Python CPU threads do not execute bytecode in parallel under the normal GIL; native extensions may release it.
  • asyncio is cooperative concurrency. Any blocking call or long CPU loop in a coroutine stalls the event loop. Use bounded queues when producers can outrun consumers, and preserve cancellation and shutdown.
  • Processes provide CPU parallelism but add startup, pickling, IPC, memory, and failure handling. Include all of those in the benchmark.
  • Start methods vary by platform and Python version. Libraries should not force a global method without owning application lifecycle.
  • Free-threaded CPython enables parallel Python threads but adds evolving overhead, synchronization requirements, and extension compatibility. Test the exact interpreter and dependency set.
Show full SKILL.md (325 more words)Show less

I/O and services

  • Use buffering for repeated small reads and writes. readinto() can reuse a buffer in measured binary pipelines but adds ownership complexity.
  • Batch database and network operations to reduce round trips. Oversized batches increase memory, lock duration, tail latency, and retry scope.
  • Avoid constructing expensive log messages when the level is disabled. Queue handlers move slow output off latency-sensitive threads but require bounded capacity, ordering, loss, and shutdown decisions.
  • Preserve flush, EOF, error, retry, ordering, cancellation, and protocol behavior when optimizing I/O.

NumPy and native acceleration

  • Chained NumPy operations can allocate full-size temporaries. Use out=, in-place operations, chunking, or fused kernels only after CPU and memory profiles show the temporary matters.
  • Check contiguity and strides when native kernels copy or traverse arrays poorly. Normalize layout once at a boundary, not repeatedly in a loop.
  • BLAS, process pools, application threads, and runtimes can each create worker pools. Measure oversubscription before limiting them with threadpoolctl or environment settings.
  • Warm Numba before benchmarking. It helps supported Python-loop work, not code already dominated by optimized NumPy kernels.
  • Cython, PyO3/Rust, GPU code, and alternative runtimes add compilation, transfer, ABI, packaging, debugging, and maintenance. Batch enough work per boundary crossing to justify them and keep a tested Python path when useful.

CPython specialization

Use dis.dis(fn, adaptive=True) after warm-up as supporting evidence for a hot loop. Do not redesign APIs to preserve one specialized opcode; specialization rules change between versions. Re-measure after Python upgrades.

Regression guards

Use narrow allocation, output-size, startup, or memory guards when the toolchain and platform are pinned. Wall-time gates require dedicated hardware or enough margin to avoid flaking; keep shared-runner timing advisory. Never compare runs with different GC modes, profilers, hooks, or calibration.

  • code-review checks a completed diff. When invoked from code-review, do not invoke it again.
  • code-simplifier runs after the gain is proven.
  • change-impact-auditor traces environment, serialization, imports, logging, and concurrency changes.
  • runtime-process-debugging owns subprocess, pipe, lifecycle, and shutdown failures.

Correctness overrides performance.

© caarlos0, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/python-performance of caarlos0/dotfiles.

Open the folder on GitHubat commit 278c761

Compare with similar skills

Python Performance next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Python Performance compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Python Performance this skillcaarlos0/dotfiles220—~1.6kAutomated safety check: PassMIT
Code Review ChecklistshareAI-lab/learn-claude-code78k5 repos~1.1kAutomated safety check: PassMIT
Merge Dependabot PRsonyx-dot-app/onyx32k1 repos~2.2kAutomated safety check: PassMIT
Kedro Babysitkedro-org/kedro11k—~4kAutomated safety check: PassCustom licence
LangBot Plugin Developmentlangbot-app/LangBot18k—~3.9kAutomated safety check: PassApache-2.0
Senior Architect Toolkitmaslennikov-ig/claude-code-orchestrator-kit2597 repos~1.2kAutomated safety check: NotesCustom licence

Similar skills

  • Code Review Checklist

    shareAI-lab/learn-claude-code

    Reviews code against a five-part checklist covering security, correctness, performance, maintainability and testing, and reports findings in a fixed format.

    78k GitHub starsUsed in 5 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Merge Dependabot PRs

    onyx-dot-app/onyx

    Triages and lands a batch of open Dependabot PRs in the Onyx repo, where main is gated exclusively by GitHub's merge queue: approves and enqueues green PRs, closes superseded duplicates, fixes…

    32k GitHub starsUsed in 1 repo~2.2k tokens
    DevelopmentAuto-check passed
  • Kedro Babysit

    kedro-org/kedro

    Run Kedro's local lint / format / type-check / tests on changed files (uses the project's pre-commit hooks, ruff, mypy, pytest, lint-imports, detect-secrets, Make targets — in the right venv), or…

    11k GitHub stars~4k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • LangBot Plugin Development

    langbot-app/LangBot

    Guides building, debugging and testing LangBot plugins: components, SDK calls, README and locale rules, SDK pitfalls and WebSocket-based testing.

    18k GitHub stars~3.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Senior Architect Toolkit

    maslennikov-ig/claude-code-orchestrator-kit

    Comprehensive software architecture skill for designing scalable, maintainable systems using ReactJS, NextJS, NodeJS, Express, React Native, Swift, Kotlin…

    259 GitHub starsUsed in 7 repos~1.2k tokens
    DevelopmentAuto-check: notes
  • Flowsint Enricher Builder

    reconurge/flowsint

    Guides building Flowsint enrichers and types: where definitions live, how the base class and vault work, and when a new type is warranted.

    9.3k GitHub stars~2.6k tokensUpdated 4 days ago
    DevelopmentAuto-check passed

More from caarlos0/dotfiles

All 20 skills in this repo
  • CLI Design

    caarlos0/dotfiles

    Design and review command-line interfaces for usability, automation, safety, accessibility, and long-term compatibility.

    220 GitHub stars~4.2k tokensUpdated today
    Auto-check passed
  • Dependabot Merge

    caarlos0/dotfiles

    Review and merge open dependency pull requests from Dependabot, Renovate and similar bots across the goreleaser organization and the caarlos0 user.

    220 GitHub stars~5k tokensUpdated today
    Auto-check passed
  • Gh CLI

    caarlos0/dotfiles

    Use GitHub CLI efficiently for pull requests, CI checks, workflow runs, logs, and merge status.

    220 GitHub stars~2.5k tokensUpdated today
    Auto-check passed
  • Tui Design

    caarlos0/dotfiles

    Design terminal user interfaces and interactive CLIs that stay usable, accessible, and scriptable.

    220 GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Dashboard

    caarlos0/dotfiles

    Design and review dashboards that are informative, honest, accessible, and visually polished, independent of any tool.

    220 GitHub stars~4.1k tokensUpdated today
    Auto-check passed
  • Gh Doc Author

    caarlos0/dotfiles

    Author and revise clear GitHub internal documentation, including design docs, proposals, decision records, runbooks, status updates, and handoffs.

    220 GitHub stars~2.2k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Python Performance

What does Python Performance do?

Profile and optimize Python CPU, memory, I/O, concurrency, and numerical performance. Python Performance is an agent skill from caarlos0/dotfiles. Profile and optimize Python CPU, memory, I/O, concurrency, and numerical performance.

When should I use Python Performance?

Python Performance fits situations like: development work in your project.

How do I install Python Performance in Claude Code?

Run `npx skills add caarlos0/dotfiles --skill python-performance -a claude-code`. Or copy the skill folder (skills/python-performance in caarlos0/dotfiles) into .claude/skills/python-performance in your project. Claude Code loads it when a task matches its description.

How do I install Python Performance in Codex?

Run `npx skills add caarlos0/dotfiles --skill python-performance -a codex`. Or copy the skill folder (skills/python-performance in caarlos0/dotfiles) into .agents/skills/python-performance in your project. Codex loads it when a task matches its description.

Can I use Python Performance in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add caarlos0/dotfiles --skill python-performance -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/python-performance, .gemini/skills/python-performance, .github/skills/python-performance and .opencode/skills/python-performance in your project.

What does Python Performance need to run?

Going by SKILL.md and its folder, Python Performance needs the command-line tools its instructions call (python). Our summary lists: Python 3.

Does Python Performance access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Python Performance safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Python Performance use?

Python Performance is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Python Performance use?

About 1.6k tokens (SKILL.md is roughly 6.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Python Performance?

Skills that share tags, products or a category with Python Performance: Code Review Checklist (shareAI-lab/learn-claude-code, 78k stars), Merge Dependabot PRs (onyx-dot-app/onyx, 32k stars), Kedro Babysit (kedro-org/kedro, 11k stars) and LangBot Plugin Development (langbot-app/LangBot, 18k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Python Performance?

caarlos0 (a GitHub user) maintains it in caarlos0/dotfiles, which has 220 GitHub stars. The repository holds 20 skills in this directory. The repository was last updated on October 7, 2026.

Source: caarlos0/dotfiles on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.