openclaw-skills/python-performance/SKILL.md
Use when profiling Python code, reducing memory usage, optimizing hot paths, choosing concurrency patterns, or reviewing performance regressions in Python services and scripts.
npx skillsauth add seaworld008/commonly-used-high-value-skills python-performanceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Python is an incredibly productive language, but it can be slow if not handled correctly. This skill provides a systematic approach to identifying bottlenecks, optimizing memory usage, and choosing the right concurrency model.
在优化之前,必须先进行测量。
针对 I/O 密集型任务(网络请求、数据库操作、文件读写)。
当纯 Python 无法满足性能要求时。
dict 的哈希查找、set 的去重、deque 的高效双端队列。for 循环追加。python -m cProfile -s cumtime script.py
# 采样 30 秒并生成 svg 火焰图
py-spy record -o profile.svg --duration 30 --pid <PID>
import asyncio
import httpx
async def fetch_url(client, url):
response = await client.get(url)
return response.status_code
async def main(urls):
async with httpx.AsyncClient() as client:
tasks = [fetch_url(client, url) for url in urls]
results = await asyncio.gather(*tasks)
print(f"Finished {len(results)} requests")
if __name__ == "__main__":
urls = ["https://example.com" for _ in range(100)]
asyncio.run(main(urls))
from numba import jit
import numpy as np
@jit(nopython=True)
def sum_of_squares(arr):
res = 0
for i in range(len(arr)):
res += arr[i] ** 2
return res
data = np.random.rand(10_000_000)
# 第一次调用会有编译开销,后续飞快
print(sum_of_squares(data))
Generated by Skill Master - Professional Edition
development
Enumerating failure modes via pre-mortem analysis. Systematically identifies failure scenarios for plans, designs, and features, scoring them with RPN/AP. Does not write code.
testing
Orchestrating specialist AI agent teams as a meta-coordinator. Decomposes requests into minimum viable chains, spawns each as an independent session in AUTORUN modes, and drives to final output. Use when a task spans multiple specialist domains, requires parallel agent execution, or needs hub-and-spoke routing across the skill ecosystem.
development
Converting document formats (Markdown/Word/Excel/PDF/HTML). Converts specs from Scribe and reports from Harvest into distributable formats; generates reusable conversion scripts. Use when converting documents, building accessibility-compliant PDFs, or creating Pandoc/LibreOffice pipelines.
testing
Curating cross-agent knowledge and guarding institutional memory. Extracts patterns from agent journals into METAPATTERNS.md, detects knowledge decay, propagates best practices, prevents organizational forgetting. Use when consolidating cross-agent insights, curating memory, or auditing knowledge decay.