diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-09-02 08:17:42 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-09-02 08:17:42 +0200 |
| commit | 6c2e06ed20cdea1a67629554d8aa1d5fcda030f9 (patch) | |
| tree | e5fa1f199a35e455917f661a62b38505afa703d7 /src/sequence/fast.zig | |
| parent | 804204db7cf1e8a28defd359d17fa72949e13eff (diff) | |
Implement sequences and tuples
Diffstat (limited to 'src/sequence/fast.zig')
| -rw-r--r-- | src/sequence/fast.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sequence/fast.zig b/src/sequence/fast.zig new file mode 100644 index 0000000..07f5de6 --- /dev/null +++ b/src/sequence/fast.zig @@ -0,0 +1,20 @@ +const c = @import("c"); +const zpy = @import("../root.zig"); + +pub const Fast = extern struct { + const Self = @This(); + + data: c.PyObject, + + pub fn size(self: *Self) !usize { + return @intCast(c.PySequence_Fast_GET_SIZE(@ptrCast(self))); + } + + pub fn get(self: *Self, index: usize) *zpy.Object { + return @ptrCast(c.PySequence_Fast_GET_ITEM(@ptrCast(self), @intCast(index)) orelse return error.Exception); + } + + pub fn items(self: *Self) [*:null][*c]zpy.Object { + return @ptrCast(c.PySequence_Fast_ITEMS(@ptrCast(self))); + } +}; |