-
Notifications
You must be signed in to change notification settings - Fork 372
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 and/or #854
Labels
Comments
For comparison, this is what Hy is doing currently to the above example. (#824 has been merged) => (print (and 1 2 3 (setv x 1) 4 5 6))
_hy_anon_var_1 = 1
if _hy_anon_var_1:
_hy_anon_var_1 = 2
if _hy_anon_var_1:
_hy_anon_var_1 = 3
if _hy_anon_var_1:
x = 1
_hy_anon_var_1 = x
if _hy_anon_var_1:
_hy_anon_var_1 = 4
if _hy_anon_var_1:
_hy_anon_var_1 = 5
if _hy_anon_var_1:
_hy_anon_var_1 = 6
print(_hy_anon_var_1)
6 Notice there are eight assignments, but the optimized version only needs three. |
scauligi
added a commit
to scauligi/hy
that referenced
this issue
Sep 28, 2023
scauligi
added a commit
to scauligi/hy
that referenced
this issue
Sep 28, 2023
scauligi
added a commit
to scauligi/hy
that referenced
this issue
Sep 30, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Depends on #824.
Related #842.
Even in the case that
and
/or
contains a statement, it may have several expressions in a row that don't need to be converted toif
branches. Hy could avoid redundant assignments by keeping those runs as expressions and only assigning the result to an anonymous variable.For example:
The text was updated successfully, but these errors were encountered: