Skip to content

perf: cache expensive @property on Fit classes - #341

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/cache-fit-properties
May 27, 2026
Merged

perf: cache expensive @property on Fit classes#341
Jammy2211 merged 1 commit into
mainfrom
feature/cache-fit-properties

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Changes expensive @property to @functools.cached_property on FitDataset, FitImaging, and FitInterferometer. These properties (model_data, residual_map, chi_squared_map, log_likelihood, etc.) were recomputing on every access despite depending only on immutable constructor args. For Delaunay inversions, model_data alone cost 5-20s per access — and downstream properties accessed it redundantly.

Closes #340

API Changes

None — same properties, same return types. Now cached after first access.

Test Plan

  • pytest passes for this repo
  • Smoke tests across workspaces

🤖 Generated with Claude Code

FitDataset, FitImaging, and FitInterferometer properties like
model_data, residual_map, chi_squared_map, and log_likelihood were
recomputing on every access despite depending only on immutable
constructor args. For Delaunay inversions model_data alone cost
5-20s — downstream properties accessed it redundantly, creating
a cascade of recomputation.

Changed @Property to @functools.cached_property. Safe because Fit
objects are constructed once and never mutated, and none of these
classes use __getstate__ or JAX pytree registration on the Fit
object itself.

Closes PyAutoArray#340

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 27, 2026
@Jammy2211
Jammy2211 merged commit dc013f9 into main May 27, 2026
6 checks passed
@Jammy2211
Jammy2211 deleted the feature/cache-fit-properties branch May 27, 2026 16:24
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 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.

perf: cache immutable @property on Fit classes

1 participant