PyOZ v0.7.0
What's New in v0.7.0
Added
- Complete Python exception hierarchy - Added all missing exception types from the CPython hierarchy, covering every exception from
BaseExceptiondown through all subclasses includingNameError,UnboundLocalError,ReferenceError,SyntaxError,IndentationError,TabError,StopAsyncIteration, and all 11 Warning types (Warning,DeprecationWarning,UserWarning,RuntimeWarning, etc.) - Ergonomic raise functions returning
Null- Allraise*functions now return@TypeOf(null)(aliased asNull), enabling one-liner error returns:return pyoz.raiseValueError("bad input"). Thenullliteral coerces to any optional type (?*PyObject,?i64,?f64, etc.) - 21 new raise functions -
raiseAssertionError,raiseFloatingPointError,raiseLookupError,raiseNameError,raiseUnboundLocalError,raiseReferenceError,raiseStopAsyncIteration,raiseSyntaxError,raiseUnicodeError,raiseModuleNotFoundError,raiseBlockingIOError,raiseBrokenPipeError,raiseChildProcessError,raiseConnectionAbortedError,raiseConnectionRefusedError,raiseConnectionResetError,raiseFileExistsError,raiseInterruptedError,raiseIsADirectoryError,raiseNotADirectoryError,raiseProcessLookupError - 17 new
PythonException.is*methods -isMemoryError,isOSError,isNotImplementedError,isOverflowError,isFileNotFoundError,isPermissionError,isTimeoutError,isConnectionError,isEOFError,isImportError,isNameError,isSyntaxError,isRecursionError,isArithmeticError,isBufferError,isSystemError,isUnicodeError ExcBaseenum expanded to 60+ variants - Users can now use any standard Python exception as a base for custom exceptions viapyoz.exception("MyError", .SyntaxError)or any other variantPyExcstruct covers the full hierarchy - Programmatic access to every built-in Python exception type__del__hook for custom cleanup - Structs can now definepub fn __del__(self: *Self) voidwhich PyOZ calls duringtp_deallocbefore freeing the Python object. This allows releasing C memory, closing file handles, invalidating resources, etc. Works in both normal and ABI3 modes with zero runtime cost for types that don't define it.Callable(ReturnType)wrapper for Python callbacks - Type-safe wrapper for accepting and invoking Python callables from Zig. Handles automatic argument marshalling (Zig→Python conversion), result conversion (Python→Zig), full refcounting, and exception propagation. Supports any number of arguments via.call(.{args}), a.callNoArgs()shortcut, andCallable(void)for callbacks with no return value. Works in ABI3 mode.__class_getitem__support (PEP 560) - Structs can declarepub const __class_getitem__ = true;to enableMyClass[int]generic type syntax. Returnstypes.GenericAliason Python 3.9+, falls back gracefully on 3.8. Works in ABI3 mode.allowThreads/allowThreadsTry- Ergonomic GIL release wrappers. Call any function without the GIL in one line:pyoz.allowThreads(compute, .{data}).allowThreadsTrysupports error-returning functions withdefer-based GIL restoration.- Freelist / Object Pooling - Structs can declare
pub const __freelist__: usize = N;to cache up to N deallocated objects for reuse, avoiding allocator overhead for frequently created/destroyed objects. Objects are automatically re-initialized on reuse. - Mixed Zig/Python packages - New
py-packages = ["mypackage"]option in[tool.pyoz]section ofpyproject.toml. Pure Python packages are included in wheels and symlinked in develop mode, enabling hybrid Zig+Python projects. - Optional constructor arguments -
__new__functions can now use optional types (?f64,?i64, etc.) for trailing parameters. Omitted arguments default tonull, enablingMyClass(1.0)wheny: ?f64andz: ?f64are optional. - Signal handling (
checkSignals) - Newpyoz.checkSignals()function for cooperative Ctrl+C / KeyboardInterrupt support in long-running Zig code. Returnserror.Interruptedwhen a signal is pending (Python exception already set). Error wrappers now preserve already-set Python exceptions instead of overwriting them.
Changed
- Raise functions now take
comptime message- All raise functions acceptcomptime message: [*:0]const u8instead of runtime strings, which enables the@TypeOf(null)return type
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.7.0.tar.gz for the source code.
Quick Start
pyoz init mymodule
cd mymodule
pyoz build
pip install dist/*.whl