Skip to content

Commit

Permalink
still one more optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
anandology committed Mar 11, 2010
1 parent 05accad commit 58c1f06
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions web/template.py
Expand Up @@ -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)
Expand Down

0 comments on commit 58c1f06

Please sign in to comment.