I have a few computationally expensive properties on some classes. These properties do not change as long as the mutable/underlying attributes do not change. Is there a way to store the expensive property, and only re-calculate it if a change has been made?
I have a few computationally expensive properties on some classes. These properties do not
Share
You can test for the other variables in your property method and use them as part of a cache key:
Now you defer calculation until you actually need the expensive value and var1 or var2 have changed.