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 value

For example, the get_family method of Item will not be calculated every time. It will only be marked as needing an update after the execution of add or remove, making it recalculated and returning the result the next time get_family is called

See also:

  • test.utils.test_refresh.RefreshTest.

class janim.utils.refresh.Refreshable(*args, **kwargs)

Bases: object

mark_refresh(func: Callable | str) Self

Marks the specified func for an update

reset_refresh() Self
class janim.utils.refresh.RefreshData

Bases: object