-
-
Notifications
You must be signed in to change notification settings - Fork 216
for i in range(a, b, c) is not translated to for (;;) loop #625
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
Comments
Just tried it and it's working, |
Maybe it is working for constants, try using variables as arguments to see the bug. |
After looking at the js source, my guess would be that the transpiler cannot know at compile time whether or not |
maybe using != instead of < or > would solve the issue when step is not given or constant 1 or -1? using range() is a major overhead since it generates array every time. Don't want to resort to using while as it hurts readability. |
Based on the
It's about <1.5x slower than directly writing it in javascript, but orders of magnitude faster than the current implementation. |
indeed, looks like a great solution for what it's worth |
Another gotcha in the for loop: Suggested solution - use temporary variable for looping and assign it to i each iteration |
Already gives
|
If range has extra arguments, it treats for loop like a loop over regular sequence.
It should be fairly trivial to make
for i in range(begin, end, step)
to translate into
for (i=begin; i < end; i += step)
The text was updated successfully, but these errors were encountered: