mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 09:23:52 -05:00
- Add initial support for Numba compilation: asm, demangling, execution Numba wraps Python functions in `Dispatcher` objects. Each dispatcher contains zero or more compiled argument-type-indexed overloads of its function. We import the user's code as a module, and emit the code from all overloads of all dispatchers that the module publicly exposes. Name mangling is odd in Numba. It uses a similar mangling syntax to C++, but also encodes non-symbol (`r"[^a-z0-9_]"`) characters as `_%02x`. This encoding yields valid identifier names, so it is not strictly invertible. Here, I have hard-coded some replacements to decode some common cases at the cost of possible clashes with ugly user-defined names. Screenshot captured via `make dev EXTRA_ARGS="--debug --language numba"`  ## To do - [x] Answer questions of #5591. - [x] Acquire a python environment. - [ ] Automatically run the python test? Locally, I have installed a virtual environment with python 3.12.3 with ```shell path/to/python -m venv venv_numba path/to/venv_numba/bin/python -m pip install numba==0.61.0 scipy>=0.16 ``` and configured its use with ```properties # compiler-explorer/etc/config/numba.local.properties compilers=&numba defaultCompiler=numba_0_61_0 group.numba.compilers=numba_0_61_0 group.numba.baseName=Numba compiler.numba_0_61_0.exe=/path/to/python3.13 compiler.numba_0_61_0.semver=0.61.0 ``` I run this python-side test file with ```python path/to/venv_numba/bin/python -m unittest etc/scripts/test_numba_wrapper.py ``` --------- Co-authored-by: Mats Jun Larsen <mats@jun.codes>