Skip to content

perf: Catch typed condition errors without a context manager - #360

Draft
khvn26 wants to merge 1 commit into
perf/06-in-listfrom
perf/07-typed-conditions-try
Draft

khvn26 wants to merge 1 commit into
perf/06-in-listfrom
perf/07-typed-conditions-try

Conversation

@khvn26

@khvn26 khvn26 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Every typed condition evaluated entered a contextlib.suppress context manager, which costs more than the comparison itself. The errors are now caught with a try statement, which costs nothing when nothing is raised.

Effect: ~280 → ~100 ns per typed condition, so about 5–11% on segment-heavy evaluations.

Part of a stack of local evaluation performance PRs; see #353 for the stack and combined results. perf/all holds the whole stack for benchmarking.

Every typed condition evaluated entered a `contextlib.suppress` context
manager, which costs more than the comparison itself. The errors are now
caught with a `try` statement, about 175 ns less per condition.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant