refactor(markers): use match statements for marker dispatch - #1370
refactor(markers): use match statements for marker dispatch#1370henryiii wants to merge 1 commit into
Conversation
Convert the isinstance/elif chains in _evaluate_markers, _format_marker, and _normalize_extras to match statements, in the same spirit as the tags.py conversion. The marker-item case now uses class patterns, so a malformed tuple raises the existing TypeError instead of failing at unpack time. Assisted-by: ClaudeCode:claude-fable-5
|
Slower: I did some of my own benchmarking and locally found significantly worse slowdowns in specific cases:
|
|
Ahh, didn't think about this being on a hot path. I know several match statements are slower than the matching if statements, often because they do more checks: Looks like it was useful anyway in finding some ways to make this faster, so not wasted. :) |
|
|
These are cases where pattern matching is natural (AST-like work is what it was
designed for).
Assisted-by: ClaudeCode:claude-fable-5