Skip to content

[mypyc] Add primitives and specialization for round() - #22568

Draft
KevinRK29 wants to merge 2 commits into
python:masterfrom
KevinRK29:round-float-performance
Draft

KevinRK29 wants to merge 2 commits into
python:masterfrom
KevinRK29:round-float-performance

Conversation

@KevinRK29

@KevinRK29 KevinRK29 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a primitive for single argument round calls on floats. The float implementation is adapted from CPython and avoids having to first create a Python float object. This also optimizes round() on ints, with a fallback for subclasses.

This makes it approximately 14× faster based on a local round(float) microbenchmark

This is for mypyc/mypyc#984

@KevinRK29 KevinRK29 changed the title [mypyc] Optimize single argument round() Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant