Skip to content

Conversation

@zxzxwu
Copy link
Collaborator

@zxzxwu zxzxwu commented Feb 9, 2026

No description provided.

@zxzxwu zxzxwu requested a review from barbibulle February 9, 2026 08:05
@zxzxwu zxzxwu force-pushed the match-case branch 2 times, most recently from 4a19e14 to aa2dfda Compare February 10, 2026 09:33
@zxzxwu
Copy link
Collaborator Author

zxzxwu commented Feb 10, 2026

Hmmm, actually match-case is sometimes even slightly slower than if-else, but it does provide better readability.

Speed: dict (prebuilt) >> getattr(f'on_{key}') handler = if-else = match-case >= dict(inline)

Copy link
Collaborator

@barbibulle barbibulle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice. Readability is more important than raw performance, especially that the difference here isn't very large.

@zxzxwu zxzxwu merged commit 6c2d6dd into google:main Feb 11, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants