### Zig Source File for Example Module Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/getting_started.md Placeholder for the Zig code that defines the 'example.hello' module's functionality. ```zig --8<-- "example/hello.zig:ex" ``` -------------------------------- ### Python Test for Pydust Module Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/getting_started.md A Python unit test to verify the functionality of the compiled Zig module. ```python --8<-- "test/test_hello.py:ex" ``` -------------------------------- ### Define Pydust Extension Module in pyproject.toml Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/getting_started.md Specifies a Zig module named 'example.hello' with its root source file in `src/hello.zig` for Pydust to build. ```toml [[tool.pydust.ext_module]] name = "example.hello" root = "src/hello.zig" ``` -------------------------------- ### Create Pydust Build Script Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/getting_started.md A Python script that uses Pydust's build functionality to compile Zig modules. ```python from pydust.build import build build() ``` -------------------------------- ### Configure pyproject.toml for Pydust Build Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/getting_started.md Modifies the `pyproject.toml` file to include Pydust as a build dependency and specify the build script. ```toml [tool.poetry] name = "your-package" packages = [ { include = "your-module" } ] + include = [ { path = "src/", format = "sdist" }, { path = "your-module/*.so", format = "wheel" } ] + [tool.poetry.build] + script = "build.py" [build-system] - requires = ["poetry-core"] + requires = ["poetry-core", "ziggy-pydust==TODO_SET_VERSION"] build-backend = "poetry.core.masonry.api" ``` -------------------------------- ### Configure ZLS Build Options Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/getting_started.md JSON configuration for the Zig Language Server (ZLS) to specify the path to the Python executable within the Poetry virtual environment. ```json { "build_options": [ { "name": "python-exe", "value": "/path/to/your/poetry/venv/bin/python", } ] } ``` -------------------------------- ### Enable Self-Managed Mode in pyproject.toml Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/getting_started.md Configures Pydust to operate in self-managed mode, allowing manual control over the `build.zig` file. ```toml [tool.pydust] + self_managed = true - [[tool.pydust.ext_module]] - name = "example.hello" - root = "example/hello.zig" ``` -------------------------------- ### Custom build.zig for Self-Managed Mode Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/getting_started.md A custom Zig build configuration file that manually adds and configures Python modules using Pydust's build helpers. ```zig const std = @import("std"); const py = @import("./pydust.build.zig"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // Each Python module consists of a library_step and a test_step const module = pydust.addPythonModule(.{ .name = "example.hello", .root_source_file = .{ .path = "example/hello.zig" }, .target = target, .optimize = optimize, }); module.library_step.addModule(..., ...); module.test_step.addModule(..., ...); } ``` -------------------------------- ### All numerical methods example (Ziggy Pydust operators) Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md An example showcasing all numerical methods in Ziggy Pydust, referencing the 'all' section from 'example/operators.zig'. ```zig --8<-- "example/operators.zig:all" ``` -------------------------------- ### Example Zig Pytest Integration Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_4_testing.md This snippet demonstrates a basic Zig test file configured for use with the Pytest plugin. It requires manual initialization and finalization of the Python interpreter within the Zig test process. ```zig --8<-- "example/pytest.zig:example" ``` -------------------------------- ### Dynamic dispatch example (Ziggy Pydust operators) Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md An example demonstrating dynamic dispatch for operators in Ziggy Pydust, referencing the 'ops' section from 'example/operators.zig'. ```zig --8<-- "example/operators.zig:ops" ``` -------------------------------- ### Create Zig Foo Object Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/index.md Defines a Zig struct 'Foo' and a function 'create_foo' to initialize and return a pointer to a 'Foo' object. This demonstrates how Pydust handles Zig struct instantiation and return types. ```zig const Foo = py.class(struct { a: u32 = 0 }); pub fn create_foo() *const Foo { return py.init(Foo, .{}); } ``` -------------------------------- ### Example Zig Module for Pydust Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/modules.md This Zig code demonstrates the structure of a Pydust module. It includes common patterns like `Self = @This();`, handling private state, and function argument conventions. ```zig --8<-- "example/modules.zig:ex" ``` -------------------------------- ### Chaining PyString Appends (Zig) Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_5_memory.md Shows an example of chaining multiple `appendSlice` calls to a Pydust PyString. This demonstrates a practical use case for `appendSlice` where the function's reference stealing behavior is beneficial for chaining operations. ```zig var s = py.PyString.fromSlice("Hello "); s = s.appendSlice("1, "); s = s.appendSlice("2, "); s = s.appendSlice("3"); return s; ``` -------------------------------- ### Instantiate Pydust Class from Python Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Shows how to instantiate a Pydust class that has an `__init__` function defined in Zig, from Python code. ```python instance = SomeClass(count=1) ``` -------------------------------- ### Instantiate Pydust Class from Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Demonstrates instantiating a Pydust class from Zig using `py.init` or `py.alloc`. `py.init` creates a Python object, while `py.alloc` allocates the Zig struct without immediate Python object creation. ```zig const some_instance = try py.init(SomeClass, .{ .count = 1 }); var some_instance = try py.alloc(SomeClass); some_instance.* = .{ .foo = 124 }; ``` -------------------------------- ### Add ziggy-pydust as a Dev Dependency Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_4_testing.md This command adds the ziggy-pydust package as a development dependency to your project using Poetry. ```bash poetry add -G dev ziggy-pydust ``` -------------------------------- ### Update pyproject.toml for Dev Dependency Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_4_testing.md This diff shows how to add `ziggy-pydust` to the development dependencies in your `pyproject.toml` file. ```diff [tool.poetry.group.dev.dependencies] + ziggy-pydust = "TODO_SET_VERSION" ``` -------------------------------- ### Defining Python Classes with Pydust Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Demonstrates how to define Python classes by wrapping Zig structs with the `py.class` function. Struct fields store instance state, and public functions become Python methods. ```APIDOC ## Defining Python Classes ### Description Classes are defined by wrapping Zig structs with the `py.class` function. Struct fields are used to store per-instance state, and public struct functions are exported as Python functions. ### Method N/A (Definition) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Instantiation (Zig) ### Description Classes can be instantiated from Zig using `py.init`. Alternatively, a class can be allocated without instantiation using `py.alloc`. ### Method N/A (Instantiation) ### Endpoint N/A ### Parameters N/A ### Request Example ```zig const some_instance = try py.init(SomeClass, .{.count = 1}); var some_instance = try py.alloc(SomeClass); ``` ### Response N/A ## Instantiation (Python) ### Description To make a Pydust class instantiable from Python, declare an `__init__` function. This function can take zero arguments as a marker. ### Method N/A (Instantiation) ### Endpoint N/A ### Parameters N/A ### Request Example ```python # Assuming a Zig class definition with __init__ ``` ### Response N/A ## Inheritance ### Description Define a subclass of another Zig Pydust class by including the parent class struct as a field. Subclasses can be instantiated from Zig or Python (if `__init__` is defined). ### Method N/A (Inheritance) ### Endpoint N/A ### Parameters N/A ### Request Example ```zig // Zig subclass definition ``` ```python # Python subclass usage ``` ### Response N/A ## Super ### Description The `py.super(Type, self)` function returns a proxy `py.PyObject` to invoke methods on the superclass, similar to Python's built-in `super()`. ### Method N/A (Superclass Access) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Properties ### Description Properties allow defining getter and setter functions for class attributes, similar to Python's `@property` decorator. Properties are defined as structs with optional `get` and `set` methods. Omitting `set` makes a property read-only. ### Method N/A (Properties) ### Endpoint N/A ### Parameters N/A ### Request Example ```zig // Zig property definition ``` ```python # Python property usage ``` ### Response N/A ## Instance Attributes ### Description Attributes are similar to properties but lack custom getters and setters. They wrap the type in a struct `{ value: T }`, requiring access via `.value` in Zig. Attributes are currently read-only. ### Method N/A (Attributes) ### Endpoint N/A ### Parameters N/A ### Request Example ```zig // Zig attribute definition ``` ```python # Python attribute usage ``` ### Response N/A ## Static Methods ### Description Static methods are defined without a `self` argument and do not have access to the class itself. ### Method N/A (Static Methods) ### Endpoint N/A ### Parameters N/A ### Request Example ```zig // Zig static method definition ``` ### Response N/A ## Zig Only Methods ### Description Methods can be defined that are not exposed to Python by using the `py.zig` wrapper. ### Method N/A (Zig Only Methods) ### Endpoint N/A ### Parameters N/A ### Request Example ```zig // Zig only method definition ``` ### Response N/A ## Dunder Methods ### Description Dunder methods (double underscore) allow overriding built-in Python operators. `object` can be a pointer to a Pydust type or `py.PyObject`. `CallArgs(root)` is a Zig struct for `args` and `kwargs`. ### Method N/A (Dunder Methods) ### Endpoint N/A ### Parameters N/A ### Request Example ```zig // Example signatures for dunder methods: const binaryfunc = fn (*Self, object) !object; const unaryfunc = fn (*Self) !object; const inquiry = fn (*Self) !bool; ``` ### Response N/A ``` -------------------------------- ### Pytest Output with Ziggy Pydust Plugin Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_4_testing.md This shows the expected output from running Pytest after integrating Zig tests. It indicates that Zig tests are collected and executed, with results like passed or failed tests displayed. ```bash ================================== test session starts ================================== platform darwin -- Python 3.11.5, pytest-7.4.0, pluggy-1.3.0 plugins: ziggy-pydust-0.2.1 collected 7 items example/pytest.zig .x [100%] ============================= 1 passed, 1 xfailed in 0.30s ============================== ``` -------------------------------- ### Make Pydust Class Instantiable from Python Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Enables Python instantiation by declaring an `__init__` function within the Pydust class definition. This function can be a simple marker or accept arguments. ```zig pub const SomeClass = py.class(struct { pub fn __init__(self: *Self, count: py.PyObject) void { self.count = count; } }, "SomeClass"); ``` -------------------------------- ### Declare Python Function with Variadic Arguments (*args, **kwargs) in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/functions.md Illustrates how to create Python functions in Zig that can handle an arbitrary number of positional arguments (*args) and keyword arguments (**kwargs) using py.Args and py.Kwargs. ```zig const py = @import("py"); fn process_args(args: py.Args, kwargs: py.Kwargs) void { std.debug.print("Positional arguments: {}\n", .{args.items}); std.debug.print("Keyword arguments: {}\n", .{kwargs.items}); } ``` -------------------------------- ### Configure Pydust External Module in pyproject.toml Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/modules.md This TOML snippet shows how to define an external Python module in `pyproject.toml` for Pydust. It specifies the module's name and the path to the corresponding Zig file. ```toml [[tool.pydust.ext_module]] name = "example.modules" # A fully-qualified python module name root = "src/modules.zig" # Path to a Zig file that exports this module. ``` -------------------------------- ### Ziggy Pydust Mapping Methods Signatures Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Specifies the signature for the __getitem__ mapping method in Ziggy Pydust, indicating it uses a 'binaryfunc'. Other mapping methods are not yet implemented. ```zig binaryfunc ``` -------------------------------- ### Implement Python Buffer Protocol in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_6_buffers.md Illustrates how to implement the Python Buffer Protocol in a Zig Pydust module by defining the `__buffer__` and `__release_buffer__` methods. This allows Zig objects to be treated as buffers by Python. ```zig pub fn protocol() void { // Implementation details for __buffer__ and __release_buffer__ } ``` -------------------------------- ### Ziggy Pydust Rich Compare Methods Signatures Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Outlines the Zig signatures for rich comparison methods (__lt__, __le__, __eq__, __ne__, __gt__, __ge__) in Ziggy Pydust. It also mentions the default behavior of __ne__ and the option to implement a single __richcompare__ function using py.CompareOp. ```zig #!zig fn(*Self, object) !bool #!zig fn(*Self, object) !bool #!zig fn(*Self, object) !bool #!zig fn(*Self, object) !bool #!zig fn(*Self, object) !bool #!zig fn(*Self, object) !bool #!zig fn(*Self) !usize #!zig fn(*Self, other: object, CompareOp) !usize ``` -------------------------------- ### Ziggy Pydust Sequence Methods Signatures Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Details the Zig signatures for sequence methods in Ziggy Pydust, specifically the length (__len__) method. Other sequence methods are noted as not yet implemented. ```zig #!zig fn(*Self) !usize ``` -------------------------------- ### Sum buffer data in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_6_buffers.md A Zig function that sums the elements of a buffer, demonstrating how to access data from objects implementing the Python Buffer Protocol without copying. It expects a buffer as input. ```zig pub fn sum(buffer: usize) usize { return buffer; } ``` -------------------------------- ### Declare Python Function with Keyword Arguments in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/functions.md Shows how to define a Python function in Zig that accepts keyword arguments with default values. This allows for more flexible function calls from Python. ```zig fn greet(name: "Alice", age: f64 = 42.0) void { std.debug.print("Hello, {s}! You are {d} years old.\n", .{ name, @intCast(u32, age), }); } ``` -------------------------------- ### Ziggy Pydust Number Methods Signatures Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Lists the Zig signatures for various number methods in Ziggy Pydust, covering arithmetic operations (add, sub, mul, divmod, pow, shifts, bitwise ops, etc.), in-place variants, and unary operations (neg, pos, abs, invert, int, float, index). It also includes the inquiry method __bool__. ```zig binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc binaryfunc unaryfunc unaryfunc unaryfunc unaryfunc unaryfunc unaryfunc unaryfunc inquiry ``` -------------------------------- ### Sum buffer data in Python Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_6_buffers.md A Python test function that verifies the `sum` functionality, likely from a Zig implementation, by passing a buffer-compliant object. It asserts the correctness of the sum operation. ```python def sum(buffer: int) -> int: return buffer ``` -------------------------------- ### Ziggy Pydust Type Methods Signatures Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Provides the Zig signatures for various type methods in Ziggy Pydust, including constructors (__init__), destructors (__del__), representation (__repr__, __str__), call (__call__), iteration (__iter__, __next__), and attribute access (__getattr__). ```zig #!zig fn() void #!zig fn(*Self) !void #!zig fn(*Self, CallArgs(root)) !void #!zig fn(*Self) void #!zig fn(*Self) !py.PyString #!zig fn(*Self) !py.PyString #!zig fn(*Self, CallArgs(root)) !py.PyObject #!zig fn(*Self) !object #!zig fn(*Self) !?object #!zig fn(*Self, object) !?object ``` -------------------------------- ### Access Pydust Property in Python Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Shows how to access and set properties defined in Zig Pydust classes from Python. ```python instance.email = "test@example.com" print(instance.email) ``` -------------------------------- ### Implement Dunder Methods in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Shows how to implement Python dunder (double underscore) methods in Zig Pydust classes to override built-in Python operators. Defines common function signatures for dunder methods. ```zig const binaryfunc = fn (*Self, py.PyObject) !py.PyObject; const unaryfunc = fn (*Self) !py.PyObject; pub const MyClass = py.class(struct { pub fn __add__(self: *Self, other: py.PyObject) !py.PyObject { // ... addition logic } }, "MyClass"); ``` -------------------------------- ### Release Python GIL (Python) Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/gil.md Demonstrates releasing the Python GIL from Python code using Pydust. This allows other Python threads to execute while the marked section of code is running. Proper management with acquire calls is essential. ```python --8<-- "test/test_gil.py:gil" ``` -------------------------------- ### Ziggy Pydust Buffer Methods Signatures Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Details the Zig signatures for buffer methods in Ziggy Pydust, including __buffer__ for accessing buffer information and __release_buffer__ for releasing buffer resources. ```zig #!zig fn (*Self, *py.PyBuffer, flags: c_int) #!zig fn (*Self, *py.PyBuffer) ``` -------------------------------- ### Access Pydust Instance Attribute in Python Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Demonstrates accessing instance attributes of Pydust classes from Python. ```python instance.name = "ExampleName" print(instance.name) ``` -------------------------------- ### Python Subclass Inheritance Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Demonstrates subclassing a Pydust class in Python, showing how to inherit functionality and potentially override methods. ```python class SubClass(BaseClass): pass ``` -------------------------------- ### Append String Slice to PyString (Zig) Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_5_memory.md Demonstrates appending a Zig slice to a Pydust PyString. It shows the necessity of calling `incref` on borrowed references before a function that steals a reference, and `decref` on newly created references. This function requires manual reference management. ```zig --8<-- "example/memory.zig:append" ``` -------------------------------- ### Zig Pydust Class Inheritance Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Illustrates defining a subclass of another Zig Pydust class by including the parent struct as a field. Subclasses can be instantiated from Zig or Python if `__init__` is defined. ```zig pub const SubClass = py.class(struct { base: BaseClass, // ... other fields }, "SubClass"); ``` -------------------------------- ### Zig Fibonacci Function for Python Extension Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/README.md This Zig code defines a Fibonacci function that can be used as a native Python extension module. It uses the `pydust` library to expose the function to Python and includes a comptime block to register the module. The function takes a `u64` argument `n` and returns a `u64` result. ```zig const py = @import("pydust"); pub fn fibonacci(args: struct { n: u64 }) u64 { if (args.n < 2) return args.n; var sum: u64 = 0; var last: u64 = 0; var curr: u64 = 1; for (1..args.n) { sum = last + curr; last = curr; curr = sum; } return sum; } comptime { py.rootmodule(@This()); } ``` -------------------------------- ### Concatenate String Slice to PyString (Zig) Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/_5_memory.md Illustrates a simpler way to concatenate a Zig slice to a Pydust PyString using `concatSlice`. This method returns a new reference without stealing, and internally handles the creation and decref of the appended slice, simplifying memory management. ```zig --8<-- "example/memory.zig:concat" ``` -------------------------------- ### Define Static Methods in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Defines static methods for Pydust classes in Zig by creating struct functions that do not take a `self` argument. ```zig pub const MyClass = py.class(struct { pub fn static_method(arg1: py.PyObject) !py.PyObject { // ... static method logic } }, "MyClass"); ``` -------------------------------- ### Declare Python Function in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/functions.md Demonstrates the basic syntax for declaring a Python function within a Zig module. This function can be called from Python. ```zig fn double(x: f64) f64 { return x * 2.0; } ``` -------------------------------- ### Acquire Python GIL (Zig/C) Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/gil.md Enables Pydust code to re-acquire the Python GIL before calling back into Python code. This is crucial for libraries written in Zig or C that utilize callbacks to ensure thread safety when interacting with Python objects. ```zig This functionality is typically demonstrated within the context of CPython C-API interactions and is not shown as a standalone Zig snippet here. The `py.gil()` function would be called within Zig code that needs to execute Python code. ``` -------------------------------- ### Release Python GIL (Zig) Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/gil.md Allows Zig code to release the Python GIL, enabling Python threads to make progress. Each call to `py.nogil()` requires a corresponding `acquire()` call. This is useful for running long-running Zig operations without blocking Python threads. ```zig --8<-- "example/gil.zig:gil" ``` -------------------------------- ### Define Zig-Only Methods in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Defines methods within a Pydust class that are only accessible from Zig, not exposed to Python, using the `py.zig` wrapper. ```zig pub const MyClass = py.class(struct { pub fn zig_only_method(self: *Self) void { // ... zig-only logic } }, "MyClass"); ``` -------------------------------- ### Define Pydust Instance Attribute in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Defines instance attributes for Pydust classes in Zig. Attributes wrap the type in a struct, requiring access via `.value` in Zig. Attributes are currently read-only. ```zig pub const MyClass = py.class(struct { name: py.Attribute(py.PyString), }, "MyClass"); ``` -------------------------------- ### Define Pydust Property in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Defines a property for a Pydust class in Zig, allowing custom getter and setter functions. Read-only properties can be created by omitting the setter. ```zig pub const MyClass = py.class(struct { email: py.Property({ get: "get_email", set: "set_email", }), pub fn get_email(self: *Self) !py.PyObject { // ... getter logic } pub fn set_email(self: *Self, value: py.PyObject) !void { // ... setter logic } }, "MyClass"); ``` -------------------------------- ### Define Python Class in Zig Source: https://github.com/spiraldb/ziggy-pydust/blob/develop/docs/guide/classes.md Defines a Python class by wrapping Zig structs with the `py.class` function. Struct fields store instance state, and public struct functions are exported as Python functions. ```zig const some_class = py.class(struct { // fields }, "some_class"); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.