Start here
What's new in 2.2
Nox 2.2 collects everything that shipped in the 2.1.x releases on the way to it. Everything here is source compatible with 2.0 and 2.1: no valid program stops compiling, and NNI v1, the Plugin API and NAPI are unchanged.
Language#
- Variadic functions (
*xs: int,**kwargs, keyword-only parameters and argument unpacking) work as documented in Functions.minandmaxnow take three or more arguments. - A
defwithout-> TreturnsNone.def greet(name: str):is the same asdef greet(name: str) -> None:. Returning a value from such a function is a type error, andnoxc fmtkeeps whichever form you wrote. - More builtins: the three-argument
pow(a, b, m),hex,octandbin,int(text, base),sum(items, start),enumerate(items, start),min/maxwithdefault=, andzipover three lists (Builtins).
def total(*xs: int) -> int:
t: int = 0
for x in xs:
t += x
return t
def greet(name: str):
print(f"hello {name}")
greet("Ada")
print(total(1, 2, 3))
print(max(4, 9, 2))
print(pow(2, 10, 1000))
print(hex(255), oct(8), bin(5))
print(int("ff", 16))hello Ada
6
9
24
0xff 0o10 0b101
255Performance#
Every number below was measured against a C reference compiled with clang -O2 (and CPython where it applies) and is reproducible with benchmarks/gate.py; the regression gate runs 39 standard-library and language jobs against a checked-in baseline.
| What | Before | Now |
|---|---|---|
f"{a}:{b}" and "item" + str(i) + "tail" chains (300k) |
13.3 ms | 4.4 ms |
nox.json.parse (50k objects) |
17.7 ms | 6.3 ms |
LRUCache (300k operations) |
790 ms | 11 ms |
Set.remove (20 000 elements, remove all) |
3.6 s | 3.9 ms |
nox.bigint (3000! and decimal output) |
22.8 ms | 2.9 ms |
nox.time.DateTime (100k create and format) |
161 ms | 19.6 ms |
nox.unicode.normalize (NFC, 20 passes) |
20.1 ms | 8.7 ms |
nox.fs.read_to_string |
one extra copy | read straight into the string |
- String building. An f-string, or a
+chain that contains a string literal, now compiles to a single allocation: plainintparts are written straight into the result instead of going through an intermediate string. Evaluation order and results are unchanged. - Collections.
Set,Counter,OrderedDictandLRUCacheshare a hash index that grows twenty times faster, andremoveis amortised O(1) with insertion order kept. - FFI. A scalar
extern defcall costs the same as the C call it wraps (0.7 ns); a zero-copy list-to-pointer hand-off is within 14% of C.
Where Nox is still behind C: the class-based collections (Set[int] about 17 times, Deque about 22 times, because each call goes through generic hashing and a pending-exception check), sha512 (C uses the CPU's SHA-512 instructions) and string-heavy code that allocates one reference-counted string per step (4 to 6 times). benchmarks/RESULTS.md has the full tables.
Smaller executables#
A program that prints one line is now 0.21 MB on macOS, 0.34 MB on Linux and 0.78 MB on Windows; cross-built Linux executables used to be 19 MB. See Reduce binary size.
Standard library#
Six modules wrap well-known C libraries: nox.lz4, nox.xxhash, nox.yyjson, nox.pcre2 (with JIT), nox.brotli and the compression half of nox.zstd. They are linked only into programs that import them. The existing pure modules are unchanged. How to use them.
Packages#
Packages carry a source label (nox, c, cpp, rust, go, zig or mixed). noxc publish checks the label against the files in the repository and the registry shows it as a badge (noxpkg).
Distribution#
- Release archives and the Windows installer include
lib/noxclibs.a, which the C-backed modules above need. Earlier 2.1.x archives do not;noxc upgradefixes that. - iOS and Android reject the C-backed modules at compile time instead of failing in the linker; for
nox.zstdonly thecompresscall is rejected,decompressworks.
Networking, security and tooling added in the final 2.1.x releases#
- Resolve, validate, connect.
nox.dns.resolve(host)is a separate, time-bounded lookup, andnox.http.request(..., connect_ip=ip)connects to an address you have checked while TLS still verifies the original host name (no DNS-rebinding window).request(..., ca_file="ca.pem")verifies HTTPS against only the CAs in that file; verification is never switched off. - Listen on one interface.
nox.http.configure(bind_address="127.0.0.1")binds the server to a single IPv4/IPv6 address (the HTTP/3 UDP listener follows). - Multi-core servers on macOS and Windows.
serve_multicoreshares one listening socket there, becauseSO_REUSEPORTdoes not balance connections on BSD; Linux keeps per-worker sockets. See the guidance on handlers that do almost no work. - Authenticated encryption.
nox.crypto.aead_seal/aead_open(ChaCha20-Poly1305, XChaCha20-Poly1305, AES-GCM). - Redis.
Client.set_read_timeout(ms)(a timeout closes the client;reconnect()), andClient.pipeline(commands). - Windows fixes. A child started with
nox.process.Commandnow inherits the parent's environment (it used to start with none, so a compiled program could not runnoxc run), andnox.terminal.write_rawworks on Windows and WebAssembly, including with redirected output. - Smaller additions.
nox.os.environ()/env_names();nox.sqliteexecuteruns every statement of a multi-statement string;noxc publish --help;noxc sbomreports abin-only package asnox:native=false;from m import (...)over several lines;and/ornarrowing of optional values.
Known limits carried to 2.3#
Nested async def (use a module-level async def and pass values as parameters), list[Task[T]] (use TaskGroup), Redis Cluster, a per-client nox.http connection pool, a portable shutdown event for Windows and WASM, and PostgreSQL read timeouts on mobile/WASM. The list is tracked in project/v2-3-yapilacaklar-2026-11.md.