Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@
## 2026-07-13 - Array.from mapping optimization
**Learning:** Using `Array.from({ length: N }).map(...)` creates an intermediate array of `undefined` values which requires memory allocation and garbage collection, adding O(N) unnecessary overhead in frequently re-rendered UI components.
**Action:** Use `Array.from({ length: N }, (_, index) => ...)` to map elements directly during array creation, avoiding intermediate allocations.
## 2026-08-14 - Replace zip(lst, lst[1:]) with inline tracking
**Learning:** Using `zip(lst, lst[1:])` to compute sequential changes in Python creates an intermediate sliced list and requires memory allocation, slowing down analysis of many segments in `section_harmony.py`.
**Action:** Replace `zip()` with an inline check that tracks `previous_chord` during the main iteration loop. This results in O(1) memory overhead and avoids O(N) list slicing.
26 changes: 0 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<<<<<<< SEARCH
durations: dict[str, float] = {}
overlapping_chords: list[str] = []

for seg_start, seg_end, chord in segments:
overlap = min(seg_end, section_end) - max(seg_start, section_start)
if overlap <= 0.0:
continue
durations[chord] = durations.get(chord, 0.0) + overlap
overlapping_chords.append(chord)

chords: list[ChordDuration] = [
{"chord": chord, "duration": duration}
for chord, duration in sorted(durations.items(), key=lambda item: (-item[1], item[0]))
]

main_chord = ""
for entry in chords:
if entry["chord"] != _NO_CHORD_LABEL:
main_chord = entry["chord"]
break

chord_changes = sum(
1
for previous, current in zip(overlapping_chords, overlapping_chords[1:], strict=False)
if previous != current
)

return {
=======
durations: dict[str, float] = {}
chord_changes = 0
previous_chord = None

for seg_start, seg_end, chord in segments:
overlap = min(seg_end, section_end) - max(seg_start, section_start)
if overlap <= 0.0:
continue
durations[chord] = durations.get(chord, 0.0) + overlap
if previous_chord is not None and previous_chord != chord:
chord_changes += 1
previous_chord = chord

chords: list[ChordDuration] = [
{"chord": chord, "duration": duration}
for chord, duration in sorted(durations.items(), key=lambda item: (-item[1], item[0]))
]

main_chord = ""
for entry in chords:
if entry["chord"] != _NO_CHORD_LABEL:
main_chord = entry["chord"]
break

return {
>>>>>>> REPLACE
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ def _summarize_one_section(
the portion of their duration that overlaps the window.
"""
durations: dict[str, float] = {}
overlapping_chords: list[str] = []
chord_changes = 0
previous_chord = None

for seg_start, seg_end, chord in segments:
overlap = min(seg_end, section_end) - max(seg_start, section_start)
if overlap <= 0.0:
continue
durations[chord] = durations.get(chord, 0.0) + overlap
overlapping_chords.append(chord)

if previous_chord is not None and previous_chord != chord:
chord_changes += 1
previous_chord = chord

chords: list[ChordDuration] = [
{"chord": chord, "duration": duration}
Expand All @@ -104,12 +108,6 @@ def _summarize_one_section(
main_chord = entry["chord"]
break

chord_changes = sum(
1
for previous, current in zip(overlapping_chords, overlapping_chords[1:], strict=False)
if previous != current
)

return {
"start_time": section_start,
"end_time": section_end,
Expand Down
Loading