Skip to content

Commit 78d9cc6

Browse files
committed
Don't use range for performance reasons
1 parent f716564 commit 78d9cc6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tornado/stack_context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,9 @@ def wrapped(*args, **kwargs):
259259
exc = _handle_exception(top, exc)
260260
else:
261261
# Otherwise take shorter path and run stack contexts in reverse order
262-
for n in range(last_ctx - 1, -1, -1):
263-
c = stack[n]
262+
while last_ctx > 0:
263+
last_ctx -= 1
264+
c = stack[last_ctx]
264265

265266
try:
266267
c.exit(*exc)

0 commit comments

Comments
 (0)