Skip to content

Avoid Importing Fastmath Functions #1116

@seanlaw

Description

@seanlaw

Currently, when we set fastmath default flags in __init__.py:

if not numba.config.DISABLE_JIT: # pragma: no cover
njit_funcs = cache.get_njit_funcs()
for module_name, func_name in njit_funcs:
module = importlib.import_module(f".{module_name}", package="stumpy")
func = getattr(module, func_name)
key = module_name + "." + func_name # e.g., core._mass
key = "STUMPY_FASTMATH_" + key.upper() # e.g., STUMPY_FASTHMATH_CORE._MASS
config._STUMPY_DEFAULTS[key] = func.targetoptions["fastmath"]

We are actually importing every single njit function. Instead, we should use AST to read the decorator value and then cross reference the values that they are represented by in config.py.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions