What's New in v0.12.2
Added
pyoz.MemoryView— New type for accepting Pythonmemoryviewobjects. Provides read-onlydata: []const u8access to the underlying buffer. Call.release()when done.pyoz.BytesLike— New unified type that accepts Pythonbytes,bytearray, ormemoryview. Provides read-onlydata: []const u8regardless of source type. Call.release()when done (no-op for bytes/bytearray).anytypeandcomptimelimitations documented — The.fromauto-scan guide now explains why functions withanytypeorcomptimeparameters are skipped and shows the typed-wrapper workaround.abi3 = trueconfiguration documented — The[tool.pyoz]configuration reference now includes theabi3option.- ByteArray, MemoryView, BytesLike in docs — Added to both the types guide and API reference.
Changed
- Removed bridge module — user module is now the root module —
pyoz initno longer generates a separate_pyoz_bridge.zigmodule. Instead, the comptime decl-analysis block is inlined directly in the user'slib.zig, making it the library's root module. This enables Zig root-module features likestd_options(custom logging, panic handlers, etc.) that were previously inaccessible because the bridge was the root. Thebuild.zigtemplate is also simplified (noWriteFiles, no extracreateModule).
Fixed
- Private fields with non-zero-initializable types — Private fields (underscore prefix) whose types contain non-nullable pointers (e.g.
std.heap.ArenaAllocator,std.mem.Allocator) no longer cause a compile error. Previously, all private fields were zero-initialized viastd.mem.zeroes, which fails for types that cannot be set to zero. Now uses a smarterinitDefaultthat: (1) uses the field's default value if one is defined in the struct, (2) zero-initializes if the type supports it, or (3) leaves the field asundefinedfor types that cannot be zeroed — the user's__new__function must initialize these fields. - Integer overflow now raises
OverflowError— Converting a Pythonintto a small Zig integer type (e.g.u8,i16,u32) now performs a range check and raisesOverflowErrorif the value doesn't fit. Previously, values were silently truncated via@truncate(C-style wrapping), sou8receiving 256 would silently become 0. - Class method errors now map to correct Python exceptions — Zig errors returned from class methods (
__getitem__,__len__,__call__,__iter__,__next__,__repr__,__hash__, comparisons, number protocol, mapping protocol, etc.) are now mapped to their corresponding Python exception types viamapWellKnownError. Previously, all class method errors were hardcoded toRuntimeError. For example,error.IndexOutOfBoundsnow raisesIndexError,error.ValueErrorraisesValueError,error.OverflowraisesOverflowError, etc. Affects 13 error sites across 8 class protocol files. ListView.get()sets IndexError/TypeError —ListView.get(index)now setsIndexErrorfor out-of-bounds access andTypeErrorfor element conversion failures, instead of returning silentnullwith no Python exception set.- Negative index on unsigned
__getitem__now raisesIndexError— Classes withusizeindex in__getitem__(mapping protocol) now raiseIndexErrorinstead ofOverflowErrorwhen accessed with a negative index. Previously, Python's C APIOverflowErrorfrom converting a negative int to unsigned was propagated directly.
Installation
Download the binary for your platform and add it to your PATH:
| Platform | Binary |
|---|---|
| Linux x86_64 | pyoz-x86_64-linux
|
| Linux ARM64 | pyoz-aarch64-linux
|
| macOS x86_64 | pyoz-x86_64-macos
|
| macOS ARM64 (Apple Silicon) | pyoz-aarch64-macos
|
| Windows x86_64 | pyoz-x86_64-windows.exe
|
| Windows ARM64 | pyoz-aarch64-windows.exe
|
Source
Download PyOZ-0.12.2.tar.gz for the source code.
Quick Start
pyoz init mymodule
cd mymodule
pyoz build
pip install dist/*.whl