Skip to content

[mypyc] Speed up fixed length tuple truthiness - #22569

Draft
KevinRK29 wants to merge 2 commits into
python:masterfrom
KevinRK29:tuple-truthiness-perf
Draft

KevinRK29 wants to merge 2 commits into
python:masterfrom
KevinRK29:tuple-truthiness-perf

Conversation

@KevinRK29

Copy link
Copy Markdown
Collaborator

Fixed-length tuple truthiness is known from the tuple’s length. So we use a constant instead of boxing the tuple, and a None check for optional non empty tuples.

This speeds up bool(t), if t, not t, and short-circuit expressions. I noticed it roughly being 7× faster fixed-tuple truthiness in the microbenchmarks I ran locally

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