Manuel, Although it doesn't hurt, I don't think it is worthwhile changing range to xrange. From the 2.5 docs:
xrange( [start,] stop[, step]) This function is very similar to range(), but returns an ``xrange object'' instead of a list. This is an opaque sequence type which yields the same values as the corresponding list, without actually storing them all simultaneously. The advantage of xrange() over range() is minimal (since xrange() still has to create the values when asked for them) except when a very large range is used on a memory-starved machine or when all of the range's elements are never used (such as when the loop is usually terminated with break). Note "minimal" advantage. xrange was intended for special-case use, not general use. And from Python 3.0, http://docs.python.org/dev/3.0/whatsnew/3.0.html xrange() renamed to range(), so range() will no longer produce a list but an iterable yielding integers when iterated over. This implies to me that range is the preferred form, and xrange is intended to go away. Eric [EMAIL PROTECTED] wrote: > Revision: 6217 > http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6217&view=rev > Author: mmetz_bn > Date: 2008-10-16 11:15:25 +0000 (Thu, 16 Oct 2008) > > Log Message: > ----------- > minor optimizations: replacing range by xrange in for loops > > Modified Paths: > -------------- > trunk/matplotlib/lib/matplotlib/axes.py > > Modified: trunk/matplotlib/lib/matplotlib/axes.py > =================================================================== > --- trunk/matplotlib/lib/matplotlib/axes.py 2008-10-15 20:53:09 UTC (rev > 6216) > +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-10-16 11:15:25 UTC (rev > 6217) > @@ -243,7 +243,7 @@ > x, y, multicol = self._xy_from_y(y) > > if multicol: > - for j in range(y.shape[1]): > + for j in xrange(y.shape[1]): > color = self._get_next_cycle_color() > seg = mlines.Line2D(x, y[:,j], > color = color, > @@ -285,7 +285,7 @@ > ret.append(seg) > > if multicol: > - for j in range(y.shape[1]): > + for j in xrange(y.shape[1]): > makeline(x[:,j], y[:,j]) > else: > makeline(x, y) > @@ -324,7 +324,7 @@ > closed = kwargs.get('closed', True) > func = makefill > if multicol: > - for j in range(y.shape[1]): > + for j in xrange(y.shape[1]): > func(x[:,j], y[:,j]) > else: > func(x, y) > @@ -372,7 +372,7 @@ > func = makefill > > if multicol: > - for j in range(y.shape[1]): > + for j in xrange(y.shape[1]): > func(x[:,j], y[:,j]) > else: > func(x, y) > @@ -3897,9 +3897,9 @@ > pass > elif align == 'center': > if orientation == 'vertical': > - left = [left[i] - width[i]/2. for i in range(len(left))] > + left = [left[i] - width[i]/2. for i in xrange(len(left))] > elif orientation == 'horizontal': > - bottom = [bottom[i] - height[i]/2. for i in > range(len(bottom))] > + bottom = [bottom[i] - height[i]/2. for i in > xrange(len(bottom))] > > else: > raise ValueError, 'invalid alignment: %s' % align > @@ -4571,7 +4571,7 @@ > elif nc == 1: > x = [x.ravel()] > else: > - x = [x[:,i] for i in range(nc)] > + x = [x[:,i] for i in xrange(nc)] > else: > raise ValueError, "input x can have no more than 2 > dimensions" > if not hasattr(x[0], '__len__'): > @@ -4665,7 +4665,7 @@ > else: > def doplot(*args): > shuffled = [] > - for i in range(0, len(args), 3): > + for i in xrange(0, len(args), 3): > shuffled.extend([args[i+1], args[i], args[i+2]]) > return self.plot(*shuffled) > > > > This was sent by the SourceForge.net collaborative development platform, the > world's largest Open Source development site. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Matplotlib-checkins mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel