Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Use collections.deque to store animation cache data.#30206
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There is aself._save_seq = []
in_init_draw
that was missed.
lib/matplotlib/animation.py Outdated
super().__init__(fig, **kwargs) | ||
# Need to reset the saved seq, since right now it will contain data | ||
# for a single frame from init, which is not what we want. | ||
self._save_seq =[] | ||
self._save_seq =collections.deque([], self._save_count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can't just clear it?
self._save_seq=collections.deque([],self._save_count) | |
self._save_seq.clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
sure, even better.
deques are exactly suited for the task at hand, and should be (here,marginally) more efficient than repeatedly slicing off the start of thelist.Also drop unneeded reference to old_frame_seq (the iterator alreadykeeps that data alive).
thanks, fixed |
deques are exactly suited for the task at hand, and should be (here, marginally) more efficient than repeatedly slicing off the start of the list.
Also drop unneeded reference to old_frame_seq (the iterator already keeps that data alive).
PR summary
PR checklist