Python learned that lesson in moving from python 2 to python 3, so Julia
creates lazy ranges by default. With the focus Julia has on performance,
this would probably an obvious choice anyway.
For the ideom you present, we actually don't even create a range (because
of inlining), but generate equivalent machine code to the similar C code.
for (int i = 1; i <= 10; i++){
#println(i)
}
Regards
torsdag 12. mars 2015 14.19.31 UTC+1 skrev Ali Rezaee følgende:
>
> Hi,
>
> I am trying to iterate over a range of numbers. I know I can do this:
>
> for i in 1:10
> println(i)
> end
>
> but, if I am not wrong, it creates a list from 1 to 10 and iterates over
> it.
> Is there a more memory efficient method so that it does not create and
> store the list? something that returns an iterator object similar to
> Python's xrange().
>
> Many thanks
>