KEMBAR78
[mypyc] Inline fast paths of integer unboxing operations by JukkaL · Pull Request #17266 · python/mypy · GitHub
Skip to content

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 19, 2024

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.

}
}
/* Haven't lost any bits, but casting to long requires extra
* care (see comment above).
Copy link
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
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