FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use collections.deque to store animation cache data. by anntzer · Pull Request #30206 · matplotlib/matplotlib · GitHub

Repository navigation

Use collections.deque to store animation cache data. - #30206

Merged
jkseppan merged 1 commit into
matplotlib:mainfrom
anntzer:ad
Jun 24, 2025
Merged

jkseppan merged 1 commit into
matplotlib:mainfrom
anntzer:ad

Conversation

anntzer commented Jun 22, 2025

Copy link
Copy Markdown
Contributor

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

QuLogic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There is a self._save_seq = [] in _init_draw that was missed.

Comment thread lib/matplotlib/animation.py Outdated
# 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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can't just clear it?

Suggested change
self._save_seq = collections.deque([], self._save_count)
self._save_seq.clear()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 the
list.

Also drop unneeded reference to old_frame_seq (the iterator already
keeps that data alive).

anntzer commented Jun 23, 2025

Copy link
Copy Markdown
Contributor Author

thanks, fixed

jkseppan added this to the v3.11.0 milestone Jun 24, 2025
jkseppan merged commit 0dcd06f into matplotlib:main Jun 24, 2025
anntzer deleted the ad branch June 24, 2025 15:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL