Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d00c21

Browse files
committed
minor optimizations: replacing range by xrange in for loops
svn path=/trunk/matplotlib/; revision=6217
1 parent 80c33ab commit 4d00c21

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def _plot_1_arg(self, y, **kwargs):
243243
x, y, multicol = self._xy_from_y(y)
244244

245245
if multicol:
246-
for j in range(y.shape[1]):
246+
for j in xrange(y.shape[1]):
247247
color = self._get_next_cycle_color()
248248
seg = mlines.Line2D(x, y[:,j],
249249
color = color,
@@ -285,7 +285,7 @@ def makeline(x, y):
285285
ret.append(seg)
286286

287287
if multicol:
288-
for j in range(y.shape[1]):
288+
for j in xrange(y.shape[1]):
289289
makeline(x[:,j], y[:,j])
290290
else:
291291
makeline(x, y)
@@ -324,7 +324,7 @@ def makefill(x, y):
324324
closed = kwargs.get('closed', True)
325325
func = makefill
326326
if multicol:
327-
for j in range(y.shape[1]):
327+
for j in xrange(y.shape[1]):
328328
func(x[:,j], y[:,j])
329329
else:
330330
func(x, y)
@@ -372,7 +372,7 @@ def makefill(x, y):
372372
func = makefill
373373

374374
if multicol:
375-
for j in range(y.shape[1]):
375+
for j in xrange(y.shape[1]):
376376
func(x[:,j], y[:,j])
377377
else:
378378
func(x, y)
@@ -3897,9 +3897,9 @@ def make_iterable(x):
38973897
pass
38983898
elif align == 'center':
38993899
if orientation == 'vertical':
3900-
left = [left[i] - width[i]/2. for i in range(len(left))]
3900+
left = [left[i] - width[i]/2. for i in xrange(len(left))]
39013901
elif orientation == 'horizontal':
3902-
bottom = [bottom[i] - height[i]/2. for i in range(len(bottom))]
3902+
bottom = [bottom[i] - height[i]/2. for i in xrange(len(bottom))]
39033903

39043904
else:
39053905
raise ValueError, 'invalid alignment: %s' % align
@@ -4571,7 +4571,7 @@ def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5,
45714571
elif nc == 1:
45724572
x = [x.ravel()]
45734573
else:
4574-
x = [x[:,i] for i in range(nc)]
4574+
x = [x[:,i] for i in xrange(nc)]
45754575
else:
45764576
raise ValueError, "input x can have no more than 2 dimensions"
45774577
if not hasattr(x[0], '__len__'):
@@ -4665,7 +4665,7 @@ def doplot(*args):
46654665
else:
46664666
def doplot(*args):
46674667
shuffled = []
4668-
for i in range(0, len(args), 3):
4668+
for i in xrange(0, len(args), 3):
46694669
shuffled.extend([args[i+1], args[i], args[i+2]])
46704670
return self.plot(*shuffled)
46714671

0 commit comments

Comments
 (0)