Files
compiler-explorer/examples
Rupert Tombs ca1ecbb2e3 Add Numba (#5592)
- 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"`

![generator
example](https://github.com/user-attachments/assets/77b8e53a-3589-4e0d-9589-10c36a026b6f)


## 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>
2025-02-19 10:41:42 -06:00
..
2022-06-20 12:24:31 +01:00
2023-06-02 08:08:57 -05:00
2025-02-12 13:41:08 -06:00
2018-10-14 01:30:35 +02:00
2021-08-26 21:57:07 +02:00
2023-03-01 06:17:26 +08:00
2022-09-20 07:42:41 -05:00
2020-09-17 21:59:34 -05:00
2022-11-27 10:39:05 -06:00
2022-05-19 13:27:23 +02:00
2022-02-11 16:19:16 +01:00
2023-12-03 11:34:25 -05:00
2024-09-30 22:19:55 -05:00
2022-08-09 07:32:19 -05:00
2023-10-11 15:01:45 -04:00
2025-01-22 00:09:35 +01:00
2019-05-26 19:45:20 +02:00
2023-01-14 15:44:14 +01:00
2021-06-02 22:58:41 +02:00
2023-03-30 18:20:56 +02:00
2020-10-08 23:58:33 +02:00
2025-02-19 10:41:42 -06:00
2018-12-15 21:31:15 +03:00
2024-12-06 17:28:47 +01:00
2021-07-06 08:32:22 -05:00
2022-07-18 20:18:36 +02:00
2022-10-05 09:32:45 +02:00
2021-07-30 16:29:37 -04:00
2021-06-29 09:39:06 +02:00
2022-04-14 02:33:13 +02:00
2024-02-12 21:50:33 -06:00
2020-09-20 01:18:54 +02:00
2022-06-24 22:07:40 +02:00
2023-08-15 22:16:36 -05:00
2023-04-10 22:49:15 -05:00
2024-11-26 16:38:40 -06:00
2024-06-10 21:29:03 -05:00
2024-10-22 06:37:40 -05:00
2018-09-09 23:36:17 +12:00