zatom is an alternative to Atom that is rewritten in zig.
using py.zig.
Note: This project was done mainly for learning purposes. After finally completing this project and doing some real world benchmarks it was actually about 5% slower and used slightly more memory (with some exceptions). I made it public to document usage of py.zig.
It aims to be mostly backwards compatible but drops several rarely used features of atom that may be breaking depending on the usage (see below). It is compatible with enaml.
To use it, simply install it and replace any imports from atom to use zatom or alternatively
you can import zatom and call zatom.install() before any normal atom imports occur.
Some reasons why you might choose this over normal atom:
- Slightly faster initialization and member access.
zatomleverages zig type generation and a metaclass to create and use types with inlined slots for up to 64 members (an arbitrary limit set). - Reduced memory usage.
- Certain members (
EventandSignal) take no storage. - Some members (eg
Bool,Enumand sometimesRange) havestaticstorage so multiple members can be bit-packed into a single slot. - zatom's uses a custom allocator that uses
PyMem_*so internal memory usage is properly tracked by tracemalloc and other tools. - No C++.
- Members in
zatomhave no runtime switchable validation modes. You cannot subclass aStrmember and make it accept anintusing a custom validate method. - The
__atom_members__is a read-only dict proxy. Certain modifications to Atom classes are not allowed. For instance a member with static storage cannot be removed. zatominstances us a 32-bit index to a pool manager on their type object so each class can only have 2**32 observed instances.- Due to their limited use, postgetattr and postsetattr modes are removed
- Notifications use fastcalls. This means observers can take at most one argument and no kwargs.