Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Low-hanging performance improvements#5664
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Instantiating Paths is expensive, but they aren't mutable, so just reusewhen possible.WeakValueDictionaries are expensive to construct. We can fix that byhandling the weakrefs ourself.
I think this is finally ready-to-merge. |
# turn the weakkey dictionary into a normal dictionary | ||
d['_parents'] = dict(six.iteritems(self._parents)) | ||
# turn the dictionary with weak values into a normal dictionary | ||
d['_parents'] = dict((k, v()) for (k, v) in |
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.
Does this need a check thatv()
returns an active ref?
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.
I currently check on deserializing (__setstate__
) where youhave to deal with it. No real need to do it in both places unless wereally care about the size of the serialization.
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.
fair enough.
PRF: Low-hanging performance improvements
@@ -93,6 +93,8 @@ | |||
(TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN, | |||
CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN) = list(xrange(8)) | |||
_empty_path = Path(np.empty((0, 2))) |
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.
FWIW, there is a fast instantiation route for Paths:https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/path.py#L173.
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 oneshould be using it.On my benchmark of:
I get a speedup from 5.04s to 3.81s.