Skip to content

[mypyc] Inline fast paths of integer unboxing operations#17266

Merged
JukkaL merged 12 commits into
masterfrom
mypyc-int-unbox-inline
Jun 17, 2024
Merged

[mypyc] Inline fast paths of integer unboxing operations#17266
JukkaL merged 12 commits into
masterfrom
mypyc-int-unbox-inline

Conversation

@JukkaL

@JukkaL JukkaL commented May 19, 2024

Copy link
Copy Markdown
Collaborator

This applies to int and native integer types.

This speeds up this micro-benchmark by up to 80% (it spends most of the time
unboxing integers):

# a is list[int]/list[i64]/...
for i in a:
    if i == 789:
        n += 1

The impact to compile time when self-compiling is below the noise floor. The generated
binary is about 0.1% larger. Since integer unboxing can be performance-critical,
this seems like a decent win.

Closes mypyc/mypyc#987. Work on mypyc/mypyc#757.

Comment thread mypyc/lib-rt/pythonsupport.c Outdated
}
}
/* Haven't lost any bits, but casting to long requires extra
* care (see comment above).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe copy the comment referred here for completeness?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't sure what it referred to, so I just removed the reference to the comment.

@JukkaL
JukkaL merged commit 31faa43 into master Jun 17, 2024
@JukkaL
JukkaL deleted the mypyc-int-unbox-inline branch June 17, 2024 09:55
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.

Faster native int unboxing

2 participants