# Elide for Python users

> How Elide compares with CPython and what changes when you switch.

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

Python is an optional component; add it once:

```bash
elide setup python
```

Then call `elide python` where you call `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` | No equivalent; `elide install --ecosystems=pypi` exits `2`. |
| `python -m venv`, `source .venv/bin/activate` | Install into a Python 3.13 venv with CPython's `pip`; set `VIRTUAL_ENV`. |
| `pytest` | No equivalent; `elide test` finds no Python tests. |
| `timeout 30 python app.py` | `elide --timeout 30s python app.py`; exits `124` when the limit is exceeded. |

## Benchmarks

Hello-world startup, measured 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

- No CPython install: `elide setup python` adds Python 3.13 and its standard library to Elide.
- Lower hello-world startup time than CPython in the benchmark above.
- `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.
- `elide --timeout 30s python app.py` bounds a run without an external `timeout`.

## Weaknesses

- No package installer: Elide does not install from PyPI, and has no `pip`.
- Some C extension modules do not load.
- No Python test runner: `elide test` finds no Python tests.
- 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)
