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

Optimize for loop over fixed-length sequence #1049

Open
JukkaL opened this issue Mar 10, 2024 · 0 comments
Open

Optimize for loop over fixed-length sequence #1049

JukkaL opened this issue Mar 10, 2024 · 0 comments
Labels

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Mar 10, 2024

If we have a for loop over a fixed-length list or tuple, we can store the iterated values in a stack-allocated array and don't need to allocate a temporary list/tuple object. Example:

for n in [x, y, z]:
    f(n)

If we are iterating over a set, we can't easily do this, since the order of items is unpredictable.

If we are iterating over unboxed types, we can probably avoid boxing/unboxing as well.

@JukkaL JukkaL added the speed label Mar 10, 2024
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