Skip to content

Replace sole use of maxdict by lru_cache. #22323

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2022
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 26, 2022

... and expand the cache size, while we're at it.

Actual deprecation of maxdict can be done in #22299.

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@greglucas
Copy link
Contributor

:) You can bring the deprecation over here if you want, happy to close the other PR. While you're at it, do you want to add a test here to make sure we are hitting the cache as expected since I made the mistake on the other one that would only cache on each text instance?

@anntzer
Copy link
Contributor Author

anntzer commented Jan 26, 2022

Done (^2)

Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

All failures appear to be CI related.

@@ -0,0 +1,4 @@
``matplotlib.cbook.maxdict`` is deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

Change name of file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@greglucas greglucas mentioned this pull request Jan 26, 2022
6 tasks
@anntzer anntzer force-pushed the unmaxdict branch 3 times, most recently from da764ff to 44d21ac Compare January 26, 2022 15:55
@anntzer
Copy link
Contributor Author

anntzer commented Jan 26, 2022

Edit: modified the implementation to not use pickle but instead key off an internally generated copy of fontprop (which the caller cannot access and thus cannot mutate).

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Modulo one comment improvement. May self-merge after adressing.

Ah, and rebase should fix the CI failure (#22326).

Comment on lines 96 to 97
# the passed-in argument do not mess up the cache. dpi is not used, but
# participates in cache invalidation (via the renderer).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# the passed-in argument do not mess up the cache. dpi is not used, but
# participates in cache invalidation (via the renderer).
# the passed-in argument do not mess up the cache.

Move that note down, because dpi is only passed on here. Clever tools will show unused in the function below and people might be tempted to remove it without consulting the context of the call site.

@tacaswell tacaswell added this to the v3.6.0 milestone Jan 26, 2022
anntzer and others added 2 commits January 27, 2022 10:58
... and expand the cache size, while we're at it.
It was used in one place in the library and there is now
a standard library lru_cache that we can take advantage of instead.
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.

5 participants