From 899c69f94c4a776a41c66129a93c4db52535d73d Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 10 Jan 2014 20:38:57 +0200 Subject: compile_for_stmt_optimised_range(): Properly handle negative & unknown steps. If step is not constant, in first approximation, we can't apply optimization, (well, we could, but need a special case for this). --- tests/basics/tests/for1.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/basics/tests/for1.py b/tests/basics/tests/for1.py index 5a2635638..c6199416c 100644 --- a/tests/basics/tests/for1.py +++ b/tests/basics/tests/for1.py @@ -7,3 +7,13 @@ def f(): print(x, y, z) f() + +# range with negative step +for i in range(3, -1, -1): + print(i) + +a = -1 +# range with non-constant step - we optimize constant steps, so this +# will be executed differently +for i in range(3, -1, a): + print(i) -- cgit v1.2.3