Permalink
Browse files

still one more optimization

  • Loading branch information...
anandology committed Mar 11, 2010
1 parent 05accad commit 58c1f06432eaf0ae7784465fa4e255a4b4792f01
Showing with 3 additions and 13 deletions.
  1. +3 −13 web/template.py
View
@@ -767,20 +767,10 @@ def setup(self, seq):
self.length = 0
self.index = 0
- seq = iter(seq)
-
- # Pre python-2.5 does not support yield in try-except.
- # This is a work-around to overcome that limitation.
- def next(seq):
- try:
- return seq.next()
- except:
- self._forloop._pop()
- raise
-
- while True:
+ for a in seq:
self.index += 1
- yield next(seq)
+ yield a
+ self._forloop._pop()
index0 = property(lambda self: self.index-1)
first = property(lambda self: self.index == 1)

0 comments on commit 58c1f06

Please sign in to comment.