Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

codelv/zatom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zatom is a zig port of Atom

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.

Features

Some reasons why you might choose this over normal atom:

  • Slightly faster initialization and member access. zatom leverages 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 (Event and Signal) take no storage.
  • Some members (eg Bool, Enum and sometimes Range ) have static storage 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++.

Breaking changes

  • Members in zatom have no runtime switchable validation modes. You cannot subclass a Str member and make it accept an int using 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.
  • zatom instances 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.

About

A zig port of the Atom

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published