From 6810c0f753a1155a3d5eabf6466611b25eda4896 Mon Sep 17 00:00:00 2001 From: Andrew Pimenov Date: Sun, 9 Aug 2026 16:11:43 +0300 Subject: [PATCH] optimize first_loss_jump with zip pairwise iteration --- src/netsleuth/exporter.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/netsleuth/exporter.py b/src/netsleuth/exporter.py index d78ab68..b9f3ce3 100644 --- a/src/netsleuth/exporter.py +++ b/src/netsleuth/exporter.py @@ -153,8 +153,7 @@ def badge(severity: str, emoji: bool, lang: str = "en") -> str: def first_loss_jump(hops: list[dict]) -> int | None: - for index, hop in enumerate(hops[:-1]): - following = hops[index + 1] + for hop, following in zip(hops, hops[1:]): if hop.get("loss_pct", 0.0) >= _LOSS_JUMP_PCT and following.get("loss_pct", 0.0) >= _LOSS_JUMP_PCT: return hop.get("ttl") return None