In python2
xrange(..)
creates the values when they are needed (ie, when your code asks for the next value...), while range()
generates all the possible values at once. No big difference when you are using small ranges, but vital if you are using large ranges, especially if your logic makes it unlikely that you use up all the generated values.# this requires 4 MB to run: sumOfSquares=0 for n in range(1000000): sumOfSquares+=n*n # this requires 8 bytes to run: sumOfSquares=0 for n in xrange(1000000): sumOfSquares+=n*n
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Your one-stop place for all your GIMP needs: gimp-forum.net