Skip to content
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

assert disabling debug option for numba jit compilation #9556

Open
kalocsaibotond opened this issue May 3, 2024 · 2 comments
Open

assert disabling debug option for numba jit compilation #9556

kalocsaibotond opened this issue May 3, 2024 · 2 comments

Comments

@kalocsaibotond
Copy link

kalocsaibotond commented May 3, 2024

Feature request

Any respectable compiler has options for levels of code optimalisation and / or debug mode, that can disable assert statements. The assert statements are very powerful tools for debugging and sanity checking.
Python's default assert disabling options are very cumbersome for the typical REPL / Jupyter notebook data science workflow, since assert statements cannot be disabled / enabled during runtime at will. However for pure python, it does not present too much problem, because of the REPL capability of the language. Though even for pure python it would be good to be able to disable assert statements at will.

For compiled code, asserts are vital for debugging. Hence it would be nice to have a debug option to disable assert statements in the numba jit-ed code, after the debugging process is finished.

@kalocsaibotond kalocsaibotond changed the title assert option disabling for numba jit compilation assert debug option disabling for numba jit compilation May 3, 2024
@kalocsaibotond kalocsaibotond changed the title assert debug option disabling for numba jit compilation assert disabling debug option for numba jit compilation May 3, 2024
@dlee992
Copy link
Contributor

dlee992 commented Jul 2, 2024

seconded.
Python provides a way (-0 or -O0) to disable assert: https://docs.python.org/3/using/cmdline.html#cmdoption-O.

@kalocsaibotond
Copy link
Author

kalocsaibotond commented Jul 2, 2024

seconded. Python provides a way (-0 or -O0) to disable assert: https://docs.python.org/3/using/cmdline.html#cmdoption-O.

I am aware of the existence of these command line options. However, the problem with these options that they are not changeable during a python session.
So if someone is doing data science in a jupyter notebook or in an ipython REPL, then one has to kill the whole session restart for debug.
This is why it is so frustrating to use assert in python. Leaving in assert with complicated condition can yield significant performance loss. Implementing additional debug branching like

if debug:
    assert complicated_condition "Complicated condition is violated."

, where debug is a global bool variable, still incur a pointless if evaluation and less readable.
Nevertheless, living in dynamically typed interpreted language without assert is feasible. However, things get quickly frustrating in a statically typed, "compiled" language without assert, such as numba jit-ed python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants