Skip to content

ImageMath: Only compute ops dict when needed #7718

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

Closed
wants to merge 3 commits into from

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Jan 15, 2024

An idea to fix #7717, only compute the ops dict when needed, when first calling eval, and functools.lru_cache it so it's only computed once.

Also rewrite as a dict comprehension. Timings for non-cached use:

200000 loops, best of 5: 1.87 usec per loop
->
200000 loops, best of 5: 1.53 usec per loop

@radarhere
Copy link
Member

I wonder if #7721 is a simpler and faster solution?

@hugovk
Copy link
Member Author

hugovk commented Jan 16, 2024

Yes, that's better, thanks!

@hugovk hugovk closed this Jan 16, 2024
@hugovk hugovk deleted the cache-ops-dict branch January 16, 2024 10:48
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.

Image.open: dictionary changed size during iteration (race condition)
2 participants