Skip to content

REF: Make numba function cache globally accessible #33621

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 4 commits into from
Apr 19, 2020

Conversation

mroeschke
Copy link
Member

  • tests passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

For all the numba accessible operations, we use a cache to store compiled JIT'd functions for performance.

This _numba_func_cache used to be an attribute of Rolling and Groupby objects before, but while working on #33388, I cannot easily rely on having access to those objects.

This PR moves _numba_func_cache to pandas/core/util/numba_.py. Since this cache is now globally shared, the key has changed from _numba_func_cache[func] = compiled_func to _numba_func_cache[(func, op)] = compiled_func

@mroeschke mroeschke requested a review from jreback April 18, 2020 05:03
@mroeschke mroeschke added the Refactor Internal refactoring of code label Apr 18, 2020
@mroeschke mroeschke added this to the 1.1 milestone Apr 18, 2020
@@ -76,6 +76,7 @@
from pandas.core.internals import BlockManager, make_block
from pandas.core.series import Series
from pandas.core.util.numba_ import (
_numba_func_cache,
Copy link
Member

Choose a reason for hiding this comment

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

If it’s cross-module, can it be non-private?

@jbrockmendel
Copy link
Member

Does this cache ever get invalidated?

@mroeschke
Copy link
Member Author

Does this cache ever get invalidated?

No. Nothing immediately comes to mind why we need to invalidate it at a certain point. Open to thoughts.

@jreback jreback merged commit 67e06ea into pandas-dev:master Apr 19, 2020
@jreback
Copy link
Contributor

jreback commented Apr 19, 2020

thanks.

@mroeschke mroeschke deleted the global_numba_cache branch April 20, 2020 00:45
CloseChoice pushed a commit to CloseChoice/pandas that referenced this pull request Apr 20, 2020
rhshadrach pushed a commit to rhshadrach/pandas that referenced this pull request May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants