Skip to content

Per-row dataChanged invalidation and PreparedRow.wraps in MultilinePreviewItemDelegate - #81

Merged
trissim merged 1 commit into
mainfrom
perf/delegate-per-row-invalidation
Nov 27, 2026
Merged

trissim merged 1 commit into
mainfrom
perf/delegate-per-row-invalidation

Conversation

@trissim

@trissim trissim commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 2.24× wall-clock speedup & 60× fewer prepare_row calls on a 124-row QTreeWidget with 1 row updating per frame (60 frames × 12 visible rows, alternating unprofiled A/B): median 52.73 ms → 23.55 ms, prepare_row 720 → 12.
  • Per-row dataChanged invalidation (src/pyqt_reactive/widgets/shared/list_item_delegate.py): MultilinePreviewItemDelegate._follow previously connected model.dataChanged to forget_rows, wiping every cached PreparedRow (and subclass per-row image caches like Toad's QtNameWaveDelegate._row_images) whenever any single row updated. Added forget_range(top_left, bottom_right, *_roles) and _rows_forgotten(rows) hook so single-row and bounded multi-row dataChanged events drop only modified (row, col, internalId) entries (with forget_rows fallback on invalid, cross-parent, or oversized ranges, and KEPT_ROWS eviction calling forget_rows() so subclasses stay consistent).
  • Deleted 3 copies of wrap-mode resolution: added PreparedRow.wraps(view) and replaced the three repeated view.wordWrap() if row.wrap_mode is None else row.wrap_mode.wrapped checks in paint, _row_wraps, and _prepared_text.

Verification

  • QT_QPA_PLATFORM=offscreen pytest -q -p no:xdist --no-cov tests/test_list_preview_wrapping.py: 28 passed in 0.45s (includes new test_data_changed_invalidates_only_modified_rows_in_list_and_tree covering both QListWidget and nested QTreeWidget rows).
  • REL_IMPORTS=0.

@trissim
trissim merged commit fbbbdf9 into main Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant