Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support boxed float literals #1003

Open
JukkaL opened this issue Jun 2, 2023 · 1 comment
Open

Support boxed float literals #1003

JukkaL opened this issue Jun 2, 2023 · 1 comment
Labels

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 2, 2023

The function i avoids explicitly boxing 12, but the function f emits a box operation:

def i() -> object:
    return 12

def f() -> object:
    return 1.2

Here's the IR:

def i():
    r0 :: object
L0:
    r0 = object 12
    inc_ref r0
    return r0

def f():
    r0 :: object
L0:
    r0 = box(float, 1.2)
    return r0

Make float literals avoid the boxing operation when they are used in a context that requires a boxed value, similar to integers.

@JukkaL JukkaL added the speed label Jun 2, 2023
@JukkaL
Copy link
Collaborator Author

JukkaL commented Jun 2, 2023

This should also work for math.pi, etc., that get translated to float literals (see python/mypy#15324).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant