Xpersona
P

python-performance

CLAWHUB · Unverified

Profiles Python code for performance bottlenecks and memory issues Skill: python-performance Owner: athola Summary: Profiles Python code for performance bottlenecks and memory issues Tags: latest:1.9.19 Version history: v1.9.19 | 2026-08-26T13:18:01.582Z | user Release v1.9.19 v1.9.17 | 2026-07-30T05:38:21.267Z | user Release v1.9.17 v1.9.16 | 2026-07-14T19:55:02.942Z | user Release v1.9.16 v1.9.14 | 2026-06-30T18:03:30.664Z | user Release v1.9.14 v1.9.13 | 2026-06-27T16:21:38.342Z

62
Rank
84
Safety
1.8k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.8K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17emme0e2m3cpf7k2jvp3a84984b8z9:nm-parseltongue-python-performance
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-athola-nm-parseltongue-python-performance/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

140,614 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
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": "\u26a1"}}
source: claude-night-market
source_plugin: parseltongue
---

> **Night Market Skill** — ported from [claude-night-market/parseltongue](https://github.com/athola/claude-night-market/tree/master/plugins/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)

## Quick Start

```python
# 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](modules/profiling-tools.md)
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](modules/optimization-patterns.md)
Ten proven optimization patterns including list comprehensions, generators, caching, string concatenation, data structures, NumPy, multiprocessing, and database operations.

### [memory-management](modules/memory-management.md)
Memory optimization techniques including leak tracking with tracemalloc and weak references for caches. Depends on profiling-tools.

### [benchmarking-tools](modules/benchmarking-tools.md)
Benchmarking tools including custom decorators and pytest-benchmark for verifying performance improvements.

### [best-practices](modules/best-practices.md)
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

_meta.json

{
  "ownerId": "kn7d107jg9jv602h9ytsegydq184a42s",
  "slug": "nm-parseltongue-python-performance",
  "version": "1.9.19",
  "publishedAt": 1787750281582
}

modules/benchmarking-tools.md

---
name: benchmarking-tools
description: Benchmarking tools including custom decorators and pytest-benchmark for performance testing
category: performance
tags: [benchmarking, testing, performance, pytest-benchmark]
dependencies: []
estimated_tokens: 173
---

# Benchmarking Tools

Tools and techniques for benchmarking Python code performance.

## Custom Benchmark Decorator

```python
import time
from functools import wraps

def benchmark(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        start = time.perf_counter()
        result = func(*args, **kwargs)
        elapsed = time.perf_counter() - start
        print(f"{func.__name__}: {elapsed:.6f}s")
        return result
    return wrapper

@benchmark
def my_function():
    # Code to benchmark
    pass
```

## pytest-benchmark

```python
# Install: pip install pytest-benchmark

def test_list_comprehension(benchmark):
    result = benchmark(lambda: [i**2 for i in range(10000)])
    assert len(result) == 10000

# Run: pytest --benchmark-compare
```

modules/best-practices.md

---
name: best-practices
description: Best practices and common pitfalls for Python performance optimization
category: performance
tags: [best-practices, guidelines, optimization, pitfalls]
dependencies: [profiling-tools, optimization-patterns]
estimated_tokens: 207
---

# Best Practices

Guidelines and common pitfalls for Python performance optimization.

## Best Practices

1. **Profile before optimizing** - Measure to find real bottlenecks
2. **Focus on hot paths** - Optimize frequently executed code
3. **Use appropriate data structures** - Dict for lookups, set for membership
4. **Cache expensive computations** - Use lru_cache
5. **Batch I/O operations** - Reduce system calls
6. **Use generators** for large datasets
7. **Consider NumPy** for numerical operations

## Common Pitfalls

- Optimizing without profiling
- Using global variables unnecessarily
- Creating unnecessary copies of data
- Not using connection pooling
- Ignoring algorithmic complexity
- Over-optimizing rare code paths

## Exit Criteria

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

modules/memory-management.md

---
name: memory-management
description: Memory optimization techniques including leak tracking with tracemalloc and weak references for caches
category: performance
tags: [memory, optimization, tracemalloc, weak-references]
dependencies: [profiling-tools]
estimated_tokens: 167
---

# Memory Management

Techniques for optimizing memory usage and preventing memory leaks.

## Tracking Memory Leaks

```python
import tracemalloc

tracemalloc.start()

# Your code here
result = memory_intensive_operation()

snapshot = tracemalloc.take_snapshot()
top_stats = snapshot.statistics('lineno')

print("Top 10 memory allocations:")
for stat in top_stats[:10]:
    print(stat)
```

## Weak References for Caches

```python
import weakref

# Allows garbage collection when no strong references
weak_cache = weakref.WeakValueDictionary()

def get_resource(key):
    resource = weak_cache.get(key)
    if resource is None:
        resource = create_expensive_resource(key)
        weak_cache[key] = resource
    return resource
```

Sponsored

Ads related to python-performance and adjacent AI workflows.