Python Pro - Advanced Python Patterns
When to Use This Skill
Invoke python-pro for:
- CatBoost model training (ml/train_models.py, feature_builder.py)
- Analytics tools optimization (async batching, caching)
- Performance profiling (bottleneck identification)
- Advanced Python patterns (decorators, generators, context managers)
- Heavy data processing on campaign datasets
- Executing ML designs from @sama-2.0
Use fastapi-production-patterns instead for:
- API endpoints, routing, middleware
- Pydantic validation, request/response models
- CORS configuration, authentication middleware
- FastAPI-specific patterns (dependency injection at API layer)
Clear Boundary:
| fastapi-production-patterns |
python-pro |
| API layer (HTTP, routing) |
Business logic (ML, analytics) |
| Pydantic, middleware, CORS |
Decorators, generators, profiling |
| FastAPI endpoints |
Core Python optimization |
Executable Scripts
Run these scripts directly for profiling and debugging:
Profile a Function
python scripts/profile_function.py app.ml.feature_builder build_features
python scripts/profile_function.py app.agents.analyst gather_evidence_async --args '{"candidate": {"list_id": "GM_30D"}}'
Compare Two Implementations
python scripts/benchmark_compare.py app.tools.v1:analyze app.tools.v2:analyze_async --runs 10
Check Memory Usage
python scripts/memory_check.py app.ml.feature_builder build_all_features --args '{"n_campaigns": 1000}'
{{PROJECT_NAME}} ML System
Use references/mission_inbox_ml.md for ML-specific documentation:
- Model locations (
ml/models/*.cbm)
- Training commands (
python ml/train_models.py)
- Feature list (110 features from
FeatureBuilder)
- How
MLPredictor serves predictions to Analyst Agent
- EPC lookup (historical, NOT ML)
- Database tables used for training
Core Patterns and Examples
Use references/patterns.md for detailed code patterns and examples across:
- Decorators (caching, timing, retries, validation)
- Generators (lazy feature building, chunking, async generators)
- Async/concurrency (batching, sync-to-async, semaphores)
- Profiling (cProfile, line_profiler, memory_profiler, benchmarking)
- Type hints and static analysis (TypedDict, Protocol, Generic, mypy/ruff/black)
- Testing (fixtures, parametrization, async tests, mocking)
- Design patterns (strategy/factory for ML and tool creation)
- Quick reference cheat sheet
Usage Guidance
- Prefer clear, typed interfaces for analytics and ML modules.
- Favor async batching when tool calls are independent.
- Profile before optimizing; keep hotspots visible.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: python-pro-23description: Write idiomatic Python code with advanced features like decorators, generators, and async/await. Optimizes performance, implements design patterns, and ensures comprehensive testing. Use for ML training, analytics tools, performance profiling, or any Python heavy lifting. Use when this capability is needed.4---56# Python Pro - Advanced Python Patterns78## When to Use This Skill910**Invoke python-pro for:**11- CatBoost model training (ml/train_models.py, feature_builder.py)12- Analytics tools optimization (async batching, caching)13- Performance profiling (bottleneck identification)14- Advanced Python patterns (decorators, generators, context managers)15- Heavy data processing on campaign datasets16- Executing ML designs from @sama-2.01718**Use fastapi-production-patterns instead for:**19- API endpoints, routing, middleware20- Pydantic validation, request/response models21- CORS configuration, authentication middleware22- FastAPI-specific patterns (dependency injection at API layer)2324**Clear Boundary:**25| fastapi-production-patterns | python-pro |26|-----------------------------|------------|27| API layer (HTTP, routing) | Business logic (ML, analytics) |28| Pydantic, middleware, CORS | Decorators, generators, profiling |29| FastAPI endpoints | Core Python optimization |3031---3233## Executable Scripts3435Run these scripts directly for profiling and debugging:3637### Profile a Function38```bash39python scripts/profile_function.py app.ml.feature_builder build_features40python scripts/profile_function.py app.agents.analyst gather_evidence_async --args '{"candidate": {"list_id": "GM_30D"}}'41```4243### Compare Two Implementations44```bash45python scripts/benchmark_compare.py app.tools.v1:analyze app.tools.v2:analyze_async --runs 1046```4748### Check Memory Usage49```bash50python scripts/memory_check.py app.ml.feature_builder build_all_features --args '{"n_campaigns": 1000}'51```5253---5455## {{PROJECT_NAME}} ML System5657Use `references/mission_inbox_ml.md` for ML-specific documentation:58- Model locations (`ml/models/*.cbm`)59- Training commands (`python ml/train_models.py`)60- Feature list (110 features from `FeatureBuilder`)61- How `MLPredictor` serves predictions to Analyst Agent62- EPC lookup (historical, NOT ML)63- Database tables used for training6465---6667## Core Patterns and Examples6869Use `references/patterns.md` for detailed code patterns and examples across:70- Decorators (caching, timing, retries, validation)71- Generators (lazy feature building, chunking, async generators)72- Async/concurrency (batching, sync-to-async, semaphores)73- Profiling (cProfile, line_profiler, memory_profiler, benchmarking)74- Type hints and static analysis (TypedDict, Protocol, Generic, mypy/ruff/black)75- Testing (fixtures, parametrization, async tests, mocking)76- Design patterns (strategy/factory for ML and tool creation)77- Quick reference cheat sheet7879---8081## Usage Guidance8283- Prefer clear, typed interfaces for analytics and ML modules.84- Favor async batching when tool calls are independent.85- Profile before optimizing; keep hotspots visible.8687---88> Converted and distributed by [TomeVault](https://tomevault.io/claim/ak-eyther) — claim your Tome and manage your conversions.89<!-- tomevault:4.0:skill_md:2026-04-15 -->