You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vis.source = vis.source no-op silently clears the texture cache #64
`Vis.setattr` clears `_textures` + `_fetched` whenever `source`,
`material_id`, or `tier` is assigned — regardless of whether the new
value differs from the old one. So:
vis=Material("stainless").vis_=vis.textures# populates cachevis.source=vis.source# no-op in value, but clears cache_=vis.textures# re-fetches
Same hazard in disguise: `vis.finish = vis.finish` (the finish setter
re-assigns source + material_id, which trip `setattr` even when the
new values equal the old).
Decision
Pick one:
(a) Short-circuit on equality — add a pre-assignment check:
def__setattr__(self, name, value):
ifnamein_IDENTITY_FIELDSand"_fetched"inself.__dict__:
ifgetattr(self, name, None) ==value:
super().__setattr__(name, value)
return# no invalidation for a no-op
...
(b) Document and leave — add a docstring note: "any assignment to
an identity field invalidates the cache, even if the new value equals
the current one. Compare first if you want to avoid re-fetch."
Recommendation
(a) — the short-circuit is three lines and makes the invariant
"the cache is valid for the current identity" stable under idempotent
assignment. The current behavior is correct (cache is never wrong
after clearing) but wasteful and surprising.
Activity
feat: 3.1.2 — milestone 1 audit follow-ups (13 issues closed)