Skip to content

Cleanup C++ code - #17458

Merged
tacaswell merged 6 commits into
matplotlib:masterfrom
QuLogic:image-cleanup
May 21, 2020
Merged

tacaswell merged 6 commits into
matplotlib:masterfrom
QuLogic:image-cleanup

Conversation

@QuLogic

@QuLogic QuLogic commented May 20, 2020

Copy link
Copy Markdown
Member

PR Summary

Fixes parsing of input arguments, as optional ones should be given a default value (though the Python side may always provide them), and cleanup the ref counts of output_array using @anntzer's patch from #15474.

Fixes the memory leak due to an extra reference.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] Documentation is sphinx and numpydoc compliant
  • [N/A] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [N/A] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

QuLogic and others added 4 commits May 20, 2020 01:43
The Python side seems to always pass the optional arguments, but
technically, these should be initialized before calling
`PyArg_ParseTupleAndKeywords` in case they aren't.
A new array is always supplied, so just check that it is the right
type/shape.

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
It only returns 0 or 1, so bool hold a better meaning here.
@QuLogic QuLogic added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: transforms and scales labels May 20, 2020
@QuLogic QuLogic added this to the v3.3.0 milestone May 20, 2020
Comment thread src/_image_wrapper.cpp Resolved

@anntzer anntzer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Haven't actually checked this fixes the memleak, but certainly looks correct.

@tacaswell tacaswell modified the milestones: v3.3.0, v3.2.2 May 20, 2020
@tacaswell

Copy link
Copy Markdown
Member

re-milestoned to 3.2.2 as this is in the c++ layer, it is a pretty limited change and the memory leak is pretty bad.

@QuLogic

QuLogic commented May 20, 2020

Copy link
Copy Markdown
Member Author

I actually found more things to cleanup from @anntzer's suggestion, and I think there's another leak on 3.2.x that isn't on master, so for 3.2.2, I think I prefer to manually open that PR.

@QuLogic QuLogic modified the milestones: v3.2.2, v3.3.0 May 20, 2020
@tacaswell

Copy link
Copy Markdown
Member

fair enough.

QuLogic added 2 commits May 20, 2020 15:32
Also, remove extra `(char*)` casts.
These functions all take `const char *` already, or return `char *`
directly.
@QuLogic QuLogic changed the title Cleanup image C++ code Cleanup C++ code May 20, 2020
@QuLogic

QuLogic commented May 20, 2020 •

Copy link
Copy Markdown
Member Author

This is a tiny bit more than the image code now, and there are still a bunch of unnecessary (char *) casts, but those can't be removed until we require Python 3.7, as before that they really were char *.

@QuLogic QuLogic mentioned this pull request May 20, 2020
2 tasks done
@tacaswell

Copy link
Copy Markdown
Member

I also manually confirmed that this fixes the leak. Thanks @QuLogic !

@tacaswell
tacaswell merged commit d132860 into matplotlib:master May 21, 2020
@QuLogic
QuLogic deleted the image-cleanup branch May 21, 2020 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Performance Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: transforms and scales

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants