optimize first_loss_jump with zip pairwise iteration

This commit is contained in:
Andrew Pimenov 2026-08-09 16:11:43 +03:00
parent 93c6ac526a
commit 6810c0f753

View file

@ -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