From 0ec9ac0388e0c9467f36a523dc5f88137c553096 Mon Sep 17 00:00:00 2001 From: "Dr. Honk" Date: Tue, 29 Sep 2026 23:51:00 +0200 Subject: [PATCH] perf(nav): compute legs lazily No need to build a whole list every time. --- nav.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nav.py b/nav.py index 44d15f6..4fe895e 100644 --- a/nav.py +++ b/nav.py @@ -79,8 +79,9 @@ def distance(a, b): def legs(route): - """Return the legs (pairs of consecutive waypoints) of a route.""" - return [(route[i], route[i + 1]) for i in range(len(route) - 1)] + """Yield the legs (pairs of consecutive waypoints) of a route.""" + for i in range(1, len(route) - 1): + yield route[i], route[i + 1] def plan(destination):