Skip to content

feat: Add new performance anti-pattern detections #29

@nnennandukwe

Description

@nnennandukwe

Summary

Expand the performance profiler to detect additional common Python anti-patterns beyond the current 6 categories.

Proposed New Patterns

  • Exception handling inside loops - Try/except catching expected conditions (slow)
  • Repeated dict/set lookups in loops - O(1) operations that could be cached outside the loop
  • List comprehension vs generator - Places where generators would save memory
  • Unbounded recursion - Functions with no depth limit that could stack overflow
  • Missing __slots__ - Classes with many instances not using __slots__ for memory
  • Type conversions in loops - int(), str() conversions done repeatedly
  • Global variable mutation - Functions that modify global state

Implementation

  1. Define patterns in src/workshop_mcp/performance_profiler/patterns.py
  2. Add detection logic in performance_checker.py
  3. Write tests in tests/test_performance_checker.py

Acceptance Criteria

  • At least 3 new patterns implemented
  • Each pattern has comprehensive test coverage
  • Documentation updated with new pattern descriptions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions