360 Secure SkillHub
360 安全技能中心

python-performance

该 Skill 面向 Python 性能优化:用 cProfile、行剖析、内存剖析和 py-spy 定位瓶颈与内存问题,提供列表推导、生成器、缓存、数据结构、NumPy、多进程、数据库等优化模式,并用 pytest-benchmark 与自定义装饰器验证改进;内容按 profiling-tools、optimization-patterns、memory-management、benchmar…

athola
athola
热度 63.57
最近更新 2026-08-26 21:19:11
分类:开发依赖:代码执行 / 内部调用大模型应用场景:调试排错 / 代码审查

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add nm-parseltongue-python-performance
Metadata
name
python-performance
description
Profiles Python code for performance bottlenecks and memory issues
version
1.9.8
triggers
["python","performance","profiling","optimization","cProfile","memory","Python code is slow or when profiling for optimization before a release"]
metadata
{"openclaw":{"homepage":"https://github.com/athola/claude-night-market/tree/master/plugins/parseltongue","emoji":"⚡"}}
source
claude-night-market
source_plugin
parseltongue

Night Market Skill — ported from claude-night-market/parseltongue. For the full experience with agents, hooks, and commands, install the Claude Code plugin.

Python Performance Optimization

Profiling and optimization patterns for Python code.

Table of Contents

  1. Quick Start

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

  • Identifying performance bottlenecks
  • Reducing application latency
  • Optimizing CPU-intensive operations
  • Reducing memory consumption
  • Profiling production applications
  • Improving database query performance

When NOT To Use

  • Async concurrency - use python-async instead
  • CPU/GPU system monitoring - use conservation:cpu-gpu-performance
  • Async concurrency - use python-async instead
  • CPU/GPU system monitoring - use conservation:cpu-gpu-performance

Modules

This skill is organized into focused modules for progressive loading:

profiling-tools

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

Ten proven optimization patterns including list comprehensions, generators, caching, string concatenation, data structures, NumPy, multiprocessing, and database operations.

memory-management

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

benchmarking-tools

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

best-practices

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

Exit Criteria

  • Profiled code to identify bottlenecks
  • Applied appropriate optimization patterns
  • Verified improvements with benchmarks
  • Memory usage acceptable
  • No performance regressions