All Notes

Ziggy Pydust

A framework for building native Python extensions in Zig
Fri Sep 08 2023

Originally posted:

Today we are open-sourcing Pydust - a framework for building native Python extensions in Zig.

As we all know, Zig is an excellent language! But more specifically, we believe it to be the best language for extending Python. Pydust makes heavy use of Zig’s C integration as well as comptime to provide a framework that, at least to us, feels wonderfully Pythonic 🐍

Here’s an incredibly contrived example:

const py = @import("pydust");

const Post = struct { title: []const u8, tag_counts: py.PyDict };

pub fn tag_count(args: struct { post: Post, tag: []const u8 = "news" }) !u64 {
    return try, args.tag) orelse 0;

comptime {

And after a poetry install

>>> import example
>>> example.tag_count({'title': 'foo', 'tag_counts': {'example': 3}}, tag='example')
>>> example.tag_count({'title': 'foo', 'tag_counts': {}})


Beyond the Zig language bindings, Pydust also ships with:


So, why are we building this? At Fulcrum, we are building a cloud native storage engine for Python arrays and data frames (aren’t tables boring?). The core of our engine is written in Zig which gives us tight control over a major performance killer: memory allocations. If you’re handling any sort of large high-dimensional data in Python, I’d love to chat!

Pydust is licensed under Apache 2.0 and can be found here: