Skip to content

Low-hanging performance improvements#5664

Merged
tacaswell merged 7 commits into
matplotlib:masterfrom
mdboom:performance
Dec 22, 2015
Merged

Low-hanging performance improvements#5664
tacaswell merged 7 commits into
matplotlib:masterfrom
mdboom:performance

Conversation

@mdboom

@mdboom mdboom commented Dec 11, 2015

Copy link
Copy Markdown
Member

Instantiating Paths is expensive, but they aren't mutable, so just reuse
when possible.

WeakValueDictionaries are expensive to construct. We can fix that by
handling the weakrefs ourself.

And cbook.popall has no reason to exist. Maybe someone's using it and it should stay, but no one should be using it.

On my benchmark of:

plt.subplots(8, 8)
plt.savefig("test.png")

I get a speedup from 5.04s to 3.81s.

Instantiating Paths is expensive, but they aren't mutable, so just reuse
when possible.

WeakValueDictionaries are expensive to construct.  We can fix that by
handling the weakrefs ourself.
@mdboom

mdboom commented Dec 22, 2015

Copy link
Copy Markdown
Member Author

I think this is finally ready-to-merge.

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.

Does this need a check that v() returns an active ref?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I currently check on deserializing (__setstate__) where you have to deal with it. No real need to do it in both places unless we really care about the size of the serialization.

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.

fair enough.

@tacaswell tacaswell added this to the proposed next point release (2.1) milestone Dec 22, 2015
tacaswell added a commit that referenced this pull request Dec 22, 2015
PRF: Low-hanging performance improvements
@tacaswell tacaswell merged commit 50ce5ff into matplotlib:master Dec 22, 2015
Comment thread lib/matplotlib/markers.py

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.

FWIW, there is a fast instantiation route for Paths: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/path.py#L173.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants