# Elide for Python users

> Switching from CPython to Elide: running Python 3.13 with the same command-line arguments, what changes, benchmarks, strengths and weaknesses.

Elide runs Python 3.13 programs with CPython's command-line arguments, from the same binary that runs JavaScript,
TypeScript, Java and Kotlin.

Python support is experimental in 1.6.0.

## Run the same code

Add the optional Python component once:

```bash
elide setup python
```

Then use `elide python` in place of `python`:

```bash
elide python app.py --name Elide              # sys.argv: ['app.py', '--name', 'Elide']
elide python -c 'import sys; print(sys.version)'
elide python -m json.tool input.json
elide run app.py                              # same program, general runner
```

These work unchanged:

- Scripts, `-c`, `-m`, `-` (standard input), and the REPL (bare `elide python`).
- Interpreter flags such as `-I`, `-E`, `-S`, `-B`, `-u`, `-O` and `-W`; the full list is in
  [Python with Elide](https://elide.help/docs/python#interpreter-options).
- The Python 3.13 standard library, including `json`, `pathlib`, `sqlite3`, `ssl`, `ctypes`, `bz2` and `lzma`.
- Packages from an existing Python 3.13 virtual environment, through `VIRTUAL_ENV`:

```bash
export VIRTUAL_ENV=/path/to/venv   # Elide reads $VIRTUAL_ENV/lib/python3.13/site-packages
elide python app.py
```

## What changes

| With CPython | With Elide |
| --- | --- |
| `python app.py` | `elide python app.py` or `elide run app.py` |
| `python -c CMD`, `python -m MODULE` | `elide python -c CMD`, `elide python -m MODULE` |
| Install CPython | `elide setup python` |
| `pip install PACKAGE` | `elide uv install PACKAGE`; requires the native launcher and pytools installed with the Python component. |
| `python -m venv`, `source .venv/bin/activate` | Packages installed through Elide use its automatic project environment. Compatible Python 3.13 external venvs also work through `VIRTUAL_ENV`. |
| `pytest` | Install pytest, then run `elide python -m pytest`; `elide test` does not discover Python tests. See [Python tests](https://elide.help/docs/python-testing). |
| `timeout 30 python app.py` | `elide --timeout 30s python app.py`; exits `124` when the limit is exceeded. |

Use `elide install --ecosystems=pypi` for declared dependencies. Package installation supports compatible wheels;
source builds and arbitrary CPython native wheels are not supported. Setup and commands:
[Packages and virtual environments](https://elide.help/docs/python-packages).

## Benchmarks

Hello-world startup with `hyperfine -N -w 10` (10 warmup runs, 100 measured) on a 24-core Linux workstation:

| Command | Mean |
| --- | --- |
| `elide run hello.py` | 4.8 ± 0.3 ms |
| `python3 hello.py` | 6.0 ± 0.3 ms |

No other Python benchmark is published for 1.6.0.

## Strengths

- `bz2` and `lzma` work without system `libbz2` or `liblzma`.
- Python calls JavaScript, and JavaScript or TypeScript imports Python modules, in one process with `--interop`.
- The same binary runs JavaScript, TypeScript and JVM code and builds JVM projects.

## Weaknesses

- `pip` is not bundled. Run unittest through `elide python -m unittest`; `elide test` does not discover Python tests.
- Some C extension modules do not load.
- Some edge cases differ from CPython 3.13: 93.8% of CPython core tests pass ([Compatibility Matrix](https://elide.help/docs/compatibility)).
- macOS has no native module isolation.
- With Python installed, WebAssembly SIMD modules are rejected; see [WebAssembly with Elide](https://elide.help/docs/wasm#limits).

## Next steps

- [Python with Elide](https://elide.help/docs/python)
- [Languages and Interop](https://elide.help/docs/languages)
- [Compatibility Matrix](https://elide.help/docs/compatibility)
