Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear memoized attribute values when geometry changes #6

Open
johnyf opened this issue Apr 29, 2014 · 2 comments
Open

clear memoized attribute values when geometry changes #6

johnyf opened this issue Apr 29, 2014 · 2 comments
Assignees
Labels
enhancement A new feature, an improvement, or other addition.

Comments

@johnyf
Copy link
Member

johnyf commented Apr 29, 2014

It is advantageous to restrict ConvexPolytope and Polytope to have immutable geometry (except for their annotation, i.e., the propositions), so that expensive attributes (e.g., Chebyshev radius and center, envelope, bounding box, etc.) need not be recomputed.

Since there is no particular mechanism to monitor whether an already computed attribute is no more up to date, these objects are in practice already immutable (also: there is no suggested way of altering them, though as of dd707a5 A and b are not yet protected).

Therefore we may also consider equipping them with a __hash__ function, though one complication would be that two Polytopes with nearly the same geometry can be created but they would have different __hash__ values associated with them.

@slivingston
Copy link
Member

Is there any motivation to make them immutable aside from avoiding usage of out-of-date memoized values?

If not, then I am opposed to this. Something instead that I recommend is to make memoization optional and disabled by default. Then, if someone explicitly enables it, it must be an active decision, and the documentation would have warnings about A and b attributes not being monitored, etc.

Another alternative is to make A and b accessible as object properties and to force memoized values to be cleared whenever they are changed.

@johnyf
Copy link
Member Author

johnyf commented Apr 30, 2014

The alternative sounds better, it has been implemented in 479e9ce (on branch overhaul). It remains to clear memoized values also for Polytope, when one of its ConvexPolytope objects is modified.

@johnyf johnyf removed the discussion label Nov 18, 2016
@johnyf johnyf self-assigned this Sep 19, 2017
@johnyf johnyf changed the title should polytopes be immutable clear memoized attribute values when geometry changes Oct 7, 2017
@johnyf johnyf added the enhancement A new feature, an improvement, or other addition. label Oct 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature, an improvement, or other addition.
Projects
None yet
Development

No branches or pull requests

2 participants