From 3d955661a31b409528b89e257b0665849c056b0c Mon Sep 17 00:00:00 2001 From: "codeflash-ai[bot]" <148906541+codeflash-ai[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 08:12:07 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20function=20`j?= =?UTF-8?q?oint=5Ftracks`=20by=2012%=20o3-mini=20I=20removed=20the=20list?= =?UTF-8?q?=20concatenation=20(which=20creates=20an=20intermediate=20list)?= =?UTF-8?q?=20and=20replaced=20it=20with=20two=20separate=20loops.=20This?= =?UTF-8?q?=20avoids=20the=20extra=20allocation=20and=20iteration,=20which?= =?UTF-8?q?=20can=20be=20beneficial=20especially=20when=20the=20lists=20ar?= =?UTF-8?q?e=20large.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/tracker/byte_tracker/core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/supervision/tracker/byte_tracker/core.py b/supervision/tracker/byte_tracker/core.py index cb46af733..1cb7af6a9 100644 --- a/supervision/tracker/byte_tracker/core.py +++ b/supervision/tracker/byte_tracker/core.py @@ -332,7 +332,12 @@ def joint_tracks( seen_track_ids = set() result = [] - for track in track_list_a + track_list_b: + for track in track_list_a: + if track.internal_track_id not in seen_track_ids: + seen_track_ids.add(track.internal_track_id) + result.append(track) + + for track in track_list_b: if track.internal_track_id not in seen_track_ids: seen_track_ids.add(track.internal_track_id) result.append(track)