Skip to content
This repository was archived by the owner on Nov 19, 2026. It is now read-only.

Brevi v0.24.4

Choose a tag to compare

@github-actions github-actions released this 03 Nov 22:06
9003008

Every one of the 48 final release-test programs from v0.24.3's runs now builds natively, with no CPython: enum, io.StringIO, json.JSONDecoder().raw_decode and path text from os and pathlib run natively, and exact fractions.Fraction, bin/hex/oct, startswith with a start index re.S/re.M and csv.writer(sys.stdout) are on the typed path. On the 813-program corpus 550 programs build typed, up from 496, and eight silent wrong outputs are fixed (re groups and tuples, rows changed in a loop, typed $ and re.split, dict keys printed as None). Release test over five runs (four on main before #171 and #172, one on the release commit): Sonnet 1.06x of Python's cost (95% range 1.03x to 1.10x), Haiku 1.03x (0.98x to 1.10x), every task passed on both sides, 120 of 120 and 117 of 120 final programs native. The run on the release commit alone gave 1.02x and 1.03x. Five checks along the way (of 2 tasks, trains and poker) failed under Brevi where CPython passed the same files; the models fixed their code and passed, and those typed-build wrong outputs are being fixed for the next release. The 3 programs that ran in CPython were split into several files, where a module Brevi could not build (a with other than open, except IndexError) sends the whole program to CPython.

  • Typed path round 3. On the 813-program corpus 550 programs build typed, up from 522, none moved off it, and the CPython shadow check finds no wrong output. j.get(k), j.get(k, []) and j.get(k, {}) on JSON values, json.load(sys.stdin), any(f(x, seen) for ...) where f changes seen, deps or [], names set inside a loop (or just before its break) and read after it, and return None from a function returning JSON now build typed. A MISSING = object() sentinel is read as None when every test of it also tests None. A loop over a set builds typed when its passes cannot depend on order (adding to sets, appending to the element's own entry, counting, setting a flag).
  • Silent wrong output fixed: dicts with different keys. When a list held dicts with different key sets ({"id": 1, "error": "bad"} next to {"id": 2, "total": "4"}), the typed build printed and dumped every key on every dict, so a missing key showed as None/null. Keys only some dicts have are now left out while unset, as in Python, and k in r and r.get(k) see whether the key is set.
  • csv.writer(sys.stdout) on the typed path. w = csv.writer(sys.stdout, lineterminator='\n') (also through out = sys.stdout used only for the writer) with w.writerow(row) and w.writerows(rows) now builds typed, quoting fields as CPython's csv module does (a field holding the delimiter, a quote or a line break is quoted, quotes doubled; delimiter= and lineterminator= literals). Of the 48 final release-suite programs, haiku_csv_join moved to the typed path and prints what python3 prints on the task's tests.
  • re.S/re.DOTALL and re.M/re.MULTILINE on the typed path. re.compile(r'\{\{(.*?)\}\}', re.S) and re.split(p, s, flags=re.S), common in template renderers, sent the program to the dynamic build; the flags (and (?s)/(?m) written in the pattern) now build typed. Silent wrong output fixed: in the typed build $ matched only at the very end, while Python's also matches before a final newline (re.search(r'z$', 'z\n')); re.split skipped empty matches (re.split(r'\b', 'a b'), Python 3.7 on splits there) and gave '' instead of None for a group that took no part.
  • io.StringIO builds natively. An in-memory text file (write, getvalue, read, readline, iteration, seek, tell, truncate, print(..., file=buf), with), and so csv.writer(io.StringIO()) and csv.DictReader(io.StringIO(text)), now take the dynamic build, also under --sandbox without # allow native. The rest of io (BytesIO, open) still runs in CPython. Both saved csv_join fallback programs print what python3 prints. Also: under --sandbox the {"path":"dynamic"} line for such programs named allow native though none was needed; it now says which modules the typed build lacks.
  • bin, hex, oct and startswith/endswith with a start index on the typed path. bin(x).count('1') and tokenizers that test s.startswith('<->', i) built over dynamic values; they now build typed (negative numbers and negative starts as in Python). Of the 48 final release-suite programs, haiku_sudoku moved to the typed path and prints what python3 prints on the task's tests.
  • json.JSONDecoder().raw_decode and json.decoder.scanstring build natively. Tokenizers that read a JSON value or string out of a longer text (v, end = json.JSONDecoder().raw_decode(s, i)) ran in CPython; they now take the dynamic build, with CPython's indexes and JSONDecodeError messages. These were the last 2 of the 48 final release-suite programs that still needed CPython (both json_query); both now print what python3 prints on the task's tests.
  • enum builds natively. class Color(Enum) with plain values or auto(), aliases, methods, properties and an __init__ taking tuple values, plus Color(1), Color['RED'], iteration, len, in, __members__, @unique, and str/int mixins (class Level(str, Enum)), now runs in the dynamic build; it used to run in CPython. repr, str, f-strings, hashing and errors (ValueError: 7 is not a valid Color, TypeError on <) print what CPython prints. IntEnum, StrEnum and Flag still run in CPython. Also: vars(SomeClass) works, and a class's attributes keep the order its body defines them in.
  • Exact fractions on the typed path. fractions.Fraction in a typed build held only denominators that divide lcm(1..32)*10, so every Python file importing fractions went to the dynamic build. A Fraction is now a reduced numerator over a denominator (64 bits each, worked in 128-bit arithmetic), so unit tables, matrix elimination and exact ratios such as 1/86400 build typed and print what CPython prints, including x.numerator, x.denominator, Fraction("3/4"), //, %, round, abs and sum(xs, Fraction(0)). A value that needs more than 64 bits stops with an error naming the limit rather than rounding.
  • More plain Python stays typed. On the 813-program corpus (bench/typed_corpus.py: saved solutions and repros), 522 build typed, up from 496 on main (386 of the 580 solutions, up from 371); 37 moved onto the typed path and every one with tests prints what python3 prints, and 11 moved off it on purpose (the silent wrong outputs below). ~x, yield [x for ...], (only,) = xs, d.setdefault(k, {})[j] = v, re.sub(pattern, repl, s) with repl a function of the program, a nested function with default arguments, and calls inside a generator inside another generator (" ".join(fmt(x) for x in r) for r in m) now build typed. A re group that took no part in the match is None, as in CPython, so m.group(2) is None stays typed.
  • Silent wrong output fixed: re groups and tuples. In typed builds print(m.group(2)) for a group that did not match printed an empty line instead of None, and print(m.groups()) showed ['a', '', 'c'] instead of ('a', None, 'c'). A list filled with tuple(cur) by a helper function (out.append(tuple(cur)) on a list passed in, or returned) printed its items as lists. All now match CPython (printing m.groups() and such lists goes to the dynamic build).
  • Silent wrong output fixed: rows changed in a loop. for r in t[2]: r[1] = v on rows held in a tuple (a table kept as (cols, order, rows)) changed copies of the rows in typed builds, so the update was lost; it now changes the rows themselves, and a loop that changes each row while also reading the rows' owner (if test(t, r): r[i] = v) builds over dynamic values. A program whose mixed lists ([1, 'a']) have the same item types as one of its real tuples printed those lists as tuples and copied them where Python shares them; it now builds over dynamic values too. Regex patterns also read \x00, \u00e9, \f, \v and \a escapes, which the typed build matched as letters.
  • Path text from os and pathlib builds natively everywhere. A program whose only uses of os and pathlib are path text (os.path.join, basename, dirname, splitext, normpath, os.sep, pathlib.PurePath) used Brevi's own copies of those functions only under --sandbox; outside it the program ran in CPython. It now builds natively in both. A program that also reaches files, processes or the environment (os.environ, os.listdir, pathlib.Path, os.path.exists) still runs those in CPython, as before.
  • Docs: the site has a Changelog page built from this file, and every diagram is a sharp SVG that opens full size on click; the architecture diagram shows the current build paths.

Prebuilt brevi compiler for Linux, macOS and Windows. brevi still needs rustc on the PATH to build programs. On Linux and macOS, sh install.sh installs rustc if it is missing and picks the right download; on Windows, install Rust with rustup and unzip the .zip. Details: https://brevi-lang.org/docs/install