refresh¶
Warning
Tips: This section covers the implementations of JAnim, which may be quite complex. If you do not have the need to delve into the source code, you may choose to read it at your discretion.
- janim.utils.refresh.register(func: T) T¶
Used to recalculate values only when needed, improving performance
When a method self.func is decorated, it remembers the return value of self.func when called, and in subsequent calls, it directly returns that value without actually calling self.func;
self.mark_refresh_required(self.func)is needed to re-call self.func to update the return valueFor example, the
get_familymethod ofItemwill not be calculated every time. It will only be marked as needing an update after the execution ofaddorremove, making it recalculated and returning the result the next timeget_familyis calledSee also:
test.utils.test_refresh.RefreshTest.
- class janim.utils.refresh.Refreshable(*args, **kwargs)¶
Bases:
object- mark_refresh(func: Callable | str) Self¶
Marks the specified
funcfor an update
- reset_refresh() Self¶
- class janim.utils.refresh.RefreshData¶
Bases:
object