From 73269f41d294c8b27c47212b25111b27bfa65c56 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 16 Aug 2026 17:35:02 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EC=84=B1=EB=8A=A5=20=EC=B5=9C=EC=A0=81=ED=99=94]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit πŸ’‘ What: transcript_search.pyμ—μ„œ μ§‘ν•©μ˜ λΆˆν•„μš”ν•œ 방어적 볡사 제거 및 μ€‘λ³΅λœ ν…μŠ€νŠΈ 속성 쑰회λ₯Ό 단일 λ³€μˆ˜λ‘œ μ΅œμ ν™”. 🎯 Why: O(N) 방어적 볡사와 쀑볡 속성 μ‘°νšŒκ°€ 반볡문 λ‚΄μ—μ„œ λΆˆν•„μš”ν•œ 연산을 μœ λ°œν•˜μ—¬ 검색 및 인덱싱 μ„±λŠ₯ μ €ν•˜λ₯Ό μ΄ˆλž˜ν•¨. πŸ“Š Impact: 인덱싱 속도 및 닀쀑 검색 μ‹œ μ„±λŠ₯ ν–₯상, λ©”λͺ¨λ¦¬ ν• λ‹Ή μ΅œμ†Œν™”. πŸ”¬ Measurement: pytest 및 ν”„λ‘œνŒŒμΌλ§μ„ 톡해 검색 속도 κ°œμ„  μ—¬λΆ€ 확인 κ°€λŠ₯. --- .jules/bolt.md | 3 +++ transcript_search.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index 341c7c91..2a713095 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -67,3 +67,6 @@ ## 2025-02-12 - [Fast Path Execution in Directory Traversal and Log Parsing] **Learning:** Checking for string existence (`if "silence_" not in stderr`) before invoking regex matchers provides significant speed improvements when parsing large blocks of text. Similarly, moving expensive I/O operations like `os.path.realpath` inside conditional blocks prevents redundant disk access when configuration (like path exclusions) isn't utilized. **Action:** When working on large text processing or disk operations, verify if early exit conditions or conditional execution can bypass the expensive system or library calls. +## 2024-08-16 - [λΆˆν•„μš”ν•œ 방어적 볡사 제거] +**ν•™μŠ΅:** [루프 λ‚΄μ—μ„œ λΉ„νŠΈ μ—°μ‚°μž(&)λ₯Ό μ‚¬μš©ν•˜μ—¬ μ§‘ν•© ꡐ집합을 μˆ˜ν–‰ν•  λ•Œ, 초기 μ§‘ν•©μ˜ 방어적 볡사본(예: set(postings))을 λ§Œλ“€μ§€ μ•Šμ•„λ„ λ©λ‹ˆλ‹€. & μ—°μ‚°μžλŠ” 본질적으둜 μƒˆλ‘œμš΄ 집합을 λ°˜ν™˜ν•˜λ―€λ‘œ, 초기 O(N) λ³΅μ‚¬λŠ” μ€‘λ³΅λ˜λ©° μ„±λŠ₯ 병λͺ© ν˜„μƒμ„ μΌμœΌν‚΅λ‹ˆλ‹€.] +**μ‹€ν–‰:** [λ°˜λ³΅λ¬Έμ—μ„œ μ§‘ν•© ꡐ집합을 μ²˜λ¦¬ν•  λ•Œ λΆˆν•„μš”ν•œ set() λ³€ν™˜μ„ ν”Όν•˜κ³  λ°”λ‘œ ν• λ‹Ήν•˜μ—¬ μ‚¬μš©ν•©λ‹ˆλ‹€.] diff --git a/transcript_search.py b/transcript_search.py index 1660c1f2..3914e5d1 100644 --- a/transcript_search.py +++ b/transcript_search.py @@ -193,12 +193,13 @@ def add(self, recording_id: str, segments: Iterable[Any]) -> int: """ added = 0 for segment in segments: + text = str(_read_attr(segment, "text")) entry = _Entry( recording_id=recording_id, start=float(_read_attr(segment, "start")), end=float(_read_attr(segment, "end")), - text=str(_read_attr(segment, "text")), - counts=Counter(tokenize(str(_read_attr(segment, "text")))), + text=text, + counts=Counter(tokenize(text)), ) position = len(self._entries) self._entries.append(entry) @@ -242,7 +243,7 @@ def search(self, query: str) -> list[Match]: if not postings: return [] candidates = ( - set(postings) if candidates is None else candidates & postings + postings if candidates is None else candidates & postings ) if not candidates: return []