Skip to content

[mypyc] Implement boxed constant integers as literals #12507

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

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Apr 1, 2022

This avoids (potentially) creating a new int object
every time we evaluate an integer literal in a context that
requires a boxed value. In any case this reduces the number
of C calls required.

This speeds up this microbenchmark by about 60%:

def f() -> None:
    for j in range(1000 * 1000):
        a = []
        for i in range(10):
            a.append(10)

In more realistic workloads the impact is hard to
measure and is likely below the noise floor.

This avoids creating a new int object every time
we evaluate an integer literal in a context that
requires a boxed value.

This speeds up this microbenchmark by about 60%:
```
def f() -> None:
    for j in range(1000 * 1000):
        a = []
        for i in range(10):
            a.append(10)
```

In more realistic workloads the impact is hard to
measure and is likely below the noise floor.
@JukkaL JukkaL changed the title Implement boxed constant integers as literals [mypyc] Implement boxed constant integers as literals Apr 1, 2022
@97littleleaf11 97littleleaf11 merged commit 0e8a03c into master Apr 5, 2022
@97littleleaf11 97littleleaf11 deleted the mypyc-boxed-int branch April 5, 2022 07:32
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.

3 participants