Repository navigation
Brevi v0.24.3
brevi check gives its verdict in well under a second, and checking or running an unchanged program again replays the cached result in about 10 ms: the median check of a new file went from 559 ms to 144 ms (60 of 65 programs under a second, up from 40), and a re-check from 60 ms to 8 ms median. Standard-library calls now run natively instead of in CPython (of 47 probe programs, 19 needed CPython before and 5 now), math and time are on the fast typed path (a math.sqrt/math.log loop over 20 million numbers takes 0.09 s, CPython 1.9 s), and two silent wrong outputs are fixed (re.findall with groups, reading a missing defaultdict key). No new release-test run; the v0.24.2 figures stand.
- Faster
check, and repeated calls are near-instant. Agents callbrevi checkandbrevi runover and over, so every call's wait counts. Three changes, measured on 65 programs (the release suite's saved repros and saved solutions; table in the pull request): (1)checkandrunmade all eight versions of the generated program up front, each a whole parse and type-inference pass, even when the first one built or was cached; now the others are made only when the ones before fail. (2) A new result cache:check,buildandrunof files that did not change replay the last result (the same output,{"path":...}line and binary) without parsing, inference or rustc, keyed on a hash of the program's files, the command and flags, theBREVI_*and Python settings, the Brevi binary and the toolchain. A re-check of an unchanged file went from 344 ms on average (up to 3.9 s) to 11 ms, a re-run from 379 ms (up to 4.7 s) to 18 ms. A refusal is replayed only for programs that import nothing an install could change. The MCP server gets this with no change. (3)checkof a file on the dynamic path runs rustc's checks instead of a full build (2.8 s to 0.5 s on one program). Type inference also copies its name tables less.--no-cache(orBREVI_NO_CACHE=1) builds from scratch,BREVI_CACHE_MBcaps the cache (default 1024 MB, least recently used out first; it was 400 entries), andBREVI_TIME=1prints how long each build stage took. Also fixed: a build into a folder that did not exist left its error in the build cache, so building again after creating the folder still failed. - Standard-library calls run natively, not in CPython. A Python file that the typed build could only finish by handing some standard-library calls to CPython (
math.gcd,itertools.product,statistics.mean,copy.deepcopy,datetime.datetime.strptime,functools.reduce,time.perf_counter) now takes the dynamic build, which has those modules natively: no libpython at run time, and it works under--sandbox. Libraries Brevi lacks (numpy, sqlite3) still run in CPython as before. Of 47 small standard-library probe programs, 19 needed CPython before and 5 now (argparse, textwrap, io, os and random; random and textwrap come next); in the 765-program corpus 11 programs moved from CPython to native, and every moved program with tests prints what python3 prints. Also fixed: one missing call such asmath.gcdsent everymath.call on its line to CPython,math.sqrtincluded. - Silent wrong output fixed:
re.findallwith groups. With two or more groupsre.findallreturns tuples ([('a', '1'), ('b', '2')]), but the typed build gave whole matches (['a1', 'b2']). Such calls now build over dynamic values; with no group or one group they stay typed. - Silent wrong output fixed: reading a missing defaultdict key. In Python
d[k]on a defaultdict puts the key in, solen(d), loops and printing see it; the typed build left the dict unchanged. A program that reads a defaultdict with a key that may be missing and also looks at its keys now builds over dynamic values (a key taken from a loop over the dict's keys, or frommin/maxof them, counts as found, so counting and grouping programs stay typed: 1 of the 765 corpus programs moved). mathandtimeon the fast typed path.math.gcd,lcm,comb,perm,factorial(big results grow past 64 bits as in Python),isclose,log(with or without a base),log2,log10,log1p,exp,expm1,sin,cos,tan,asin,acos,atan,atan2, the hyperbolic functions,hypot,fabs,trunc,degrees,radians,copysign,fmod,isnan,isinf,isfinite, the constantspi,e,tau,infandnan, andtime.time,perf_counterandmonotonicnow build typed, whether imported withimport mathorfrom math import gcd, pi. Domain errors are aValueErroranexceptcatches, as in CPython, andmath.sqrt(-1)raises instead of giving nan. A loop ofmath.sqrtandmath.logover 20 million numbers runs in 0.09 s (CPython: 1.9 s). Of the 47 probes,mathandtimeprograms moved from the dynamic build to the typed one; no program in the corpus left the typed path.- Docs: a What runs native table lists, module by module, which functions the typed build has, which run in the dynamic build, and which still need CPython.
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