From 227cf2470be615cff0f8faa6e61eadc3ae088a22 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 18 May 2026 03:31:35 +0000 Subject: [PATCH] perf(orbital): defer point formatting in pass prediction loop Co-authored-by: d3mocide <136547209+d3mocide@users.noreply.github.com> --- backend/api/routers/orbital.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/api/routers/orbital.py b/backend/api/routers/orbital.py index 73b34753..d0df5ef2 100644 --- a/backend/api/routers/orbital.py +++ b/backend/api/routers/orbital.py @@ -187,14 +187,16 @@ async def get_passes( r_ecef = teme_to_ecef(r, jd, fr) az, el, rng = ecef_to_topocentric(obs_ecef, r_ecef, lat, lon) - point = { - "t": t.strftime("%Y-%m-%dT%H:%M:%SZ"), - "az": round(az, 2), - "el": round(el, 2), - "slant_range_km": round(rng, 3), - } - if el >= min_elevation: + # Performance optimization: defer string formatting and dictionary allocation + # until *after* checking elevation. This avoids massive overhead since the + # vast majority of evaluated points in an orbit fall below the observer's horizon. + point = { + "t": t.strftime("%Y-%m-%dT%H:%M:%SZ"), + "az": round(az, 2), + "el": round(el, 2), + "slant_range_km": round(rng, 3), + } if not in_pass: in_pass = True current_pass_points = []