-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Range optimization has semantical issues #565
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
Labels
Comments
A temporary workaround would be to change it to:
;-) |
For reference, the following also has issues (when the iterated variable is written to):
|
dpgeorge
added a commit
that referenced
this issue
Dec 11, 2014
Now you can assign to the range variable within the for loop and it will still work. Partially addresses issue #565.
dpgeorge
added a commit
that referenced
this issue
Dec 12, 2014
You can now assign to the range end variable and the for-loop still works correctly. This fully addresses issue #565. Also fixed a bug with the stack not being fully popped when breaking out of an optimised for-loop (and it's actually impossible to write a test for this case!).
Optimised for-loop now has correct semantics. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's example:
On uPy, this ends loop prematurely, while expected semantics of range is that it captures value it was initialized with, not reference to variable.
But what really made me look into this is the gross performance difference of using range with constant expression vs one with var as arg. My guess proper semantics would be to load the end value on stack at the beginning of iteration and use that afterwards...
The text was updated successfully, but these errors were encountered: