Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flag to enable/disable numba JIT compilation?

Tags:

python

numba

Does anyone know if there is a way to (in code) disable/enable numba JIT tags for debugging purposes?

Currently, I'm commenting them all out using a select and replace in my IDE however, there must be a way of doing so automatically.

I've already tried using a flag for nopython like:

USE_NOPYTHON = False

@numba.jit(nopython=USE_NOPYTHON)
...

This doesn't disable jit...

Currently doing this manually:

@numba.jit(nopython=True)
def foo():
    ...

# -->

# @numba.jit(nopython=True)
def foo():
    ...

However, I would love if something like this was possible (without the ugly IF statements of course):

USE_JIT = False

if USE_JIT:
    @numba.jit(nopython=True)
    def foo():
        ...
else:
    def foo():
        ...
like image 744
Dyllan M Avatar asked Mar 06 '26 23:03

Dyllan M


1 Answers

Found my answer:

  1. pip install pyyaml

  2. you need to create a file called ".numba_config.yaml" in the directory you typically call your script from.

  3. within the yaml file, put the key "DISABLE_JIT" equal to the value you wish (true/false).

There are many other flags you can use, here is my reference: https://numba.pydata.org/numba-doc/dev/reference/envvars.html#environment-variables

NOTE: when your .yaml file is called ".numba_config.yaml" there is no need to prepend "NUMBA_" to the flag name if you're going off the list found in the reference link.

like image 77
Dyllan M Avatar answered Mar 09 '26 13:03

Dyllan M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!