A Python 3 surface for x-lang: indentation is grouping, statements are not expressions, and there is one integer type that goes all the way up.
$ x -l python
>>> def fact(n):
... return 1 if n <= 1 else n * fact(n - 1)
>>> print(fact(20))
2432902008176640000x-python is a lang: a different surface language loaded over an x-lang
dialect. Where x-lang and Python spell something the same way, Python is free
to mean something different by it — # opens a comment here, and ' opens a
string. The terms are in x-lang's
lang contract.
Two suites measure it.
The bundle's own suite: 1,198 tests, 0 failed, 2 pending, across 129
spec files (CI on main, 2026-11-10, against x-lang v0.46.0 and against
x-lang main). It covers the tokenizer and line structure, expressions and
statements, scope, the operator protocol, exact integers, floats and complex
numbers, str and its methods, f-strings and % formatting, bytes,
bytearray and memoryview, lists, tuples, dicts and sets, slicing,
comprehensions, functions, keyword arguments and decorators, generators and
yield from, classes with multiple bases, super, descriptors and the
special-method hooks, exceptions, with, import, eval and exec, and
the interactive session.
The conformance suite: 592 of 646 cases pass (last recorded 2026-10-17).
Each case is a whole Python program from MicroPython's test corpus, compared
on its whole stdout against a CPython 3.14 run. CI does not run it: the run
is serial and takes about an hour. make score prints the table by group,
worst first.
The modules a program can import are listed under The standard library; most of CPython's are not here yet.
It is paired with x-lang v0.67.0; bundle.xon is the row that says so. No
release has been cut.
Python has no vendor-neutral conformance suite. The de-facto standard is
CPython's Lib/test, which is unittest-based, so unittest, io and much
of the standard library must work before the first assertion runs; it is
dense with @cpython_only and impl_detail; and it is PSF-licensed rather
than MIT.
MicroPython's tests/ was written for a subset implementation. At v1.29.0:
| suite | .py files |
run under CPython 3.14 unmodified |
|---|---|---|
basics/ |
576 | 562 |
float/ |
69 | 69 |
import/ |
30 | 30 |
unicode/ |
25 | 21 |
| 700 | 682 |
The files are small, import nothing, and assert by printing: one program,
one stdout blob, which is the layout of a .spec.md case. Only 65 of the
576 in basics/ carry a .exp file; for the rest upstream generates the
expectation by running CPython, and so does this bundle.
CPython is the oracle, not MicroPython. Where CPython refuses a file,
upstream's .exp records MicroPython's own behaviour, and those files are
excluded. Of the 700, 646 become spec cases. The 54 that do not are listed
by name and reason in tests/conformance/SKIPPED.md, which make gen
writes.
No release has been cut, so there is no pin for x --install-bundle to
fetch. From a clone:
make install # into the x on your PATH
PREFIX=$HOME/.local make install # or a particular prefixmake uninstall removes it again. An installed x searches
<share>/bundles/*/bundle.xon, so a lang is installed when its files are there.
Inside an x-lang checkout, x searches that checkout's deps/bundles/ and
does not see an installed lang. X_BUNDLE_DIR names the bundles explicitly in
either case:
X_BUNDLE_DIR=$HOME/.local/share/x/bundles/ x -l python # the installed one
X_BUNDLE_DIR=/path/to/x-python/.. x -l python # a checkout, uninstalledx -l python # interactive
x -l python -f program.py # batchx-lang boots the dialect bundle.xon declares, arms this bundle's module root,
lib/, imports the entry python/run and calls its main.
make install ends with x --image -l python, which writes the booted lang
to a state image; x -l python then loads the image instead of reading the
sources, for as long as the image's key matches the library and engine.
x --no-image -l python boots from source.
With a terminal, the prompt is x-lang's line editor reading Python: arrow
keys and the readline chords, history that outlives the session, Tab over the
keywords and builtins, and colour applied as you type — keywords, literals,
comments, decorators, and brackets by nesting depth with the pair beside the
cursor marked. A line ending in : opens a block that continues under ...
until a blank line, as CPython's own prompt does.
The bundle registers all of that as the lang "python" with x-lang's
x/repl/lang, which is what lets one session hold both prompts:
>>> def sq(n):
... return n * n
...
>>> lang("x")
> (py-sq 12)
144
> (lang python)
>>> sq(12)
144
Python's names live in the shared base under a py- prefix, so a value or a
function made at one prompt is there at the other. lang("x") is Python's
spelling of the switch and (lang python) is x-lang's; both are calls to the
same registry.
Without a terminal — a pipe — there is no editor, and the bundle's own loop reads Python from stdin, block by block, as before.
X=/path/to/x-lang/x.sh make test # the bundle's own suite
X=/path/to/x-lang/x.sh make test-boot # one program through `x -l python`
make gen # fetch the pinned corpus, generate tests/conformance/
make score # pass/total per group, worst first
make conformance # the same run, case by case
make clean # drop deps/ and tests/conformance/
make card # docs/card.md: its format, and every program rundocs/card.md is the reference page: the language in tables, and programs that are run, each line beside what it prints.
Without X the suite takes the x on PATH. An installed x older than the
checkout reports failures the platform has since fixed.
make test-boot boots through the wrapper on the dialect bundle.xon
declares, from source, and runs a short program. The suite loads the bundle
on the full-tower amalgam, which binds more platform names than that dialect
does, so a name the bundle reads and never imports shows only under
test-boot, as Unbound SYMBOL.
make install asks $(X) --share-dir where to put the bundle. A checkout
answers with its own root, which is not a path -l searches there: install
into a <share> tree, or use X_BUNDLE_DIR.
The conformance run is serial: score.sh sets PARALLEL=1, because the
per-process allocation ceiling bounds one interpreter and the platform
runner would otherwise start one per CPU. It wants a machine running no
other x suite; under memory pressure cases fail that pass alone. A single
group runs with
sh tests/spec-runner.sh tests/conformance/GROUP.spec.md.
make gen runs CPython twice over every program in the corpus, at
PYTHONHASHSEED=0 and at 1, and excludes any whose output differs.
Nothing generated is committed. deps/ is the fetched corpus, verified
against the digest in tools/conformance/upstream.pin.xon;
tests/conformance/ is derived from it and from the CPython that was the
oracle. make clean drops both.
import NAME asks three places, in order:
- the program's
sys.modules; - the modules this runtime builds itself, written in x: each is a static
method of the class
PyModule(lib/python/modules.x), named for the module; - the files: each directory on
sys.path, then the bundle's ownstdlib/, which holds the library's modules written in Python.
So a program's own keyword.py beside it is imported ahead of the library's,
as in CPython; a built-in such as sys or math cannot be replaced that way.
One difference: stdlib/ is not an entry on sys.path but is searched after
all of it, so a directory a program appends to sys.path still comes
before the library. The directory is found at each search with
(Bundle root "python"), so it moves with the bundle.
In Python, wherever the runtime already supports what the module needs:
add stdlib/NAME.py (or a package, stdlib/NAME/__init__.py). Nothing else
is shared: no table, no list in x.
In x, when it needs the platform or the runtime's own values: add
lib/python/NAME.x, a scoped module python/NAME that imports python/core
for what it reads, and ends with its row:
(import python/modules PyModule)
...
(PyModule def-static! (lit NAME) (fn (_ cls) (python-NAME-module)))
(provide python/NAME python-NAME-module)
then add (import python/NAME) to the list at the end of
lib/python/core.x, which is what loads it into the boot.
Either way, add a spec file under tests/specs/ whose expected output is a
real CPython 3.14 run of the same program, and a row to the table below.
Keep the table sorted, one module a row, so two branches adding modules
rarely touch the same lines.
| Module | Written in | Where |
|---|---|---|
array |
x | lib/python/array.x |
bisect |
Python | stdlib/bisect.py |
builtins |
x | lib/python/runtime-flow.x |
cmath |
x | lib/python/cmath.x |
collections |
x | lib/python/collections.x |
copy |
Python | stdlib/copy.py |
enum |
Python | stdlib/enum.py |
errno |
x | lib/python/runtime-flow.x |
functools |
Python | stdlib/functools.py |
gc |
x | lib/python/runtime-flow.x |
heapq |
Python | stdlib/heapq.py |
io |
x | lib/python/io.x |
itertools |
Python | stdlib/itertools.py |
json |
Python | stdlib/json/ |
keyword |
Python | stdlib/keyword.py |
math |
x | lib/python/runtime-flow.x |
operator |
Python | stdlib/operator.py |
os |
x | lib/python/os.x |
random |
Python | stdlib/random.py, on lib/python/_random.x |
re |
Python | stdlib/re.py, on lib/python/_sre.x |
string |
Python | stdlib/string.py |
struct |
x | lib/python/struct.x |
sys |
x | lib/python/sys.x |
textwrap |
Python | stdlib/textwrap.py |
traceback |
x | lib/python/runtime-flow.x |
types |
x | lib/python/runtime-flow.x |
weakref |
Python | stdlib/weakref.py, on lib/python/_weakref.x |
Packages such as requests need sockets and TLS. bundle.xon declares the
helium dialect, which reaches nothing raw; moving to radon for socket is a
decision to make deliberately, and its dialect note says so. Until then,
nothing here opens a connection.
- Python values on x's type system: Python's values are x types, registered on the running base.
- NUL bytes and the string layer: how a
strand abytescarry a NUL.
docs/ design notes
bundle.xon name, dialect, release pairing, entry, grammar
lib/python/run.x the entry
lib/python/base.x the language, assembled
lib/python/core.x the core: one module in several files
lib/python/tokens.x the lexical layer, on its own tokenizer base
lib/python/parse.x tokens to forms
lib/python/types.x Python's values, as x types
lib/python/str.x the code point sequence, and the codec under it
lib/python/bytes.x the byte sequence, and the algorithms over it
lib/python/memoryview.x memoryview
lib/python/format.x the % string-formatting operator
lib/python/runtime-num.x arithmetic, the operator protocol, numeric builtins
lib/python/runtime-seq.x comparison, lists, dicts and iteration
lib/python/runtime-str.x attributes, str's methods, the format-spec language
lib/python/runtime-obj.x print, float repr, complex, exceptions and classes
lib/python/runtime-call.x keyword calls, super, sets, the rendering builtins
lib/python/runtime-flow.x modules, with, tuples and generators
lib/python/runtime-py-type.x type objects, constructors and slicing
lib/python/util.x list walks the bundle shares
lib/python/modules.x the table of built-in modules, the class PyModule
lib/python/array.x cmath.x collections.x deque.x io.x os.x struct.x sys.x
the importable modules
lib/python/repl.x the interactive session
lib/python/line.x the line editor's seams
lib/python/lexer.x syntax.x the highlighting grammar
stdlib/ the standard library's modules written in Python
tests/spec-runner.sh sources the platform's shared runner
tests/gen-harness.sh writes tests/lib/harness.gen.x (generated)
tests/boot.sh what `make test-boot` runs
tests/specs/ the bundle's own suite
tests/modules/ the modules and files the import and io specs read
tools/conformance/
upstream.pin.xon the corpus: commit, digest, licence, suites
fetch.sh fetch, verify, unpack into deps/
gen-specs.sh gen-specs.py corpus -> .spec.md, with CPython as oracle
score.sh the ranked table
tools/check/ the if-ladder check CI runs
bundle.xon declares helium, and the bundle imports the libraries Python's
data model needs:
- Python 3 has one integer type and it is arbitrary-precision:
2 ** 200is neither an error nor a float. That isx/num/bigint. 1 / 2is0.5: true division always produces a float. That isx/num/tower.
The numeric tower loads with its analysers compiled
(x/boot/tower-compiled), through x-lang's own assembler.
Python is Guido van Rossum's language, first released in 1991; Python 3 (2008) is the only target here, and it is the version that made the choices this bundle's dialect note leans on — one unbounded integer type, true division, text as Unicode. Python has a reference manual rather than a standard, and its behaviour is ultimately defined by what CPython does — which is why the scoreboard above treats CPython as the oracle rather than any document.
- The Python Language Reference — as close to a specification as exists
- Data model — the chapter an implementer actually lives in
- MicroPython — the subset implementation whose test corpus this bundle scores against
MIT No Attribution (MIT-0). See LICENSE.
The MicroPython corpus this bundle scores against is MIT and is not vendored
here — it is fetched and verified from the pin in
tools/conformance/upstream.pin.xon.