一键导入
python-perf
Performant Python for scientific computing — vectorization, NumPy anti-patterns, preallocation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Performant Python for scientific computing — vectorization, NumPy anti-patterns, preallocation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Before writing new code — search existing implementations, topical audits, READMEs, file-header caveats
After implementing — update file headers, README, topical audits; note duplication
Navigate and debug OrbitalWar / SpaceCraft — design, truss sim, combat, radiosity, orbits; hub to docs and tests
Diagnostic plots/visualizations — shared utilities, output paths, plot style conventions
Dedicated documentation work — OKF format, topical audits, extract-overview and inline-doc workflows
Writing new code — inventory-first, module-vs-script placement, no-new-files, STOP triggers for duplication
| name | python-perf |
| description | Performant Python for scientific computing — vectorization, NumPy anti-patterns, preallocation |
| trigger | {"glob":["**/*.py","**/tests/**/*","**/*bench*.py","**/*perf*.py"]} |
Python is the harness, not the engine. Call NumPy or OpenCL kernels on as many items at once as possible to minimize harness overhead. Use advanced array slicing. NEVER write low-level hot loops in Python.
for i in range(len(array)): result[i] = array[i] * 2result = array * 2np.meshgrid, slicing, broadcasting, or OpenCL kernelsarray *= 2 vs array = array * 2)array[mask] for conditional selectionarray[:, :, 0] for channel extractionarray.reshape(-1) for flattening# WRONG: 1M Python iterations
for i in range(nx):
for j in range(ny):
result[i,j] = grid[i,j] * weight
# CORRECT: Single NumPy operation
result = grid * weight
# WRONG: Nested loops + stack overhead
positions = []
for ix in range(nx):
for iy in range(ny):
positions.append([x[ix], y[iy], z])
positions = np.array(positions)
# CORRECT: 3D grid directly, minimum allocation
xx, yy, zz = np.meshgrid(x, y, z, indexing='ij')
# Use xx, yy, zz directly as 3D arrays
# WRONG: Python loop with condition
for i in range(len(data)):
if data[i] > threshold:
result[i] = data[i] * scale
# CORRECT: Vectorized
mask = data > threshold
result[mask] = data[mask] * scale