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

separate out optimization tricks into a separate parser #39

Open
atsepkov opened this issue Mar 29, 2015 · 0 comments
Open

separate out optimization tricks into a separate parser #39

atsepkov opened this issue Mar 29, 2015 · 0 comments

Comments

@atsepkov
Copy link
Owner

There are some compile-time optimizations RS already does, here are some examples:

for i in range(n):
    ...
for i in range(n, -1, -1):
    ...
for i in dir(obj):
    ...

Which compile into i++, i--, and for ... in loops respectively. These are scattered and hard to follow in the code. Also, due to them occurring at the time of output, the compiler doesn't have the ability to retroactively modify code that has already been output (i.e. removing the range implementation since the only call to it got optimized out). Moving the optimizer out into its own module would allow it to be more durable, consistent and aggressive.

For example, in addition to optimizing [1 to 5] to range(1, 5), we could also optimize it to [1,2,3,4,5] because both start and end are constants.

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

No branches or pull requests

1 participant