Python · Design

Design

4.0.0-rc.1 · 3ee5e534

  • A thin layer over the C ABI. One module per header, types, model, encode and train, one method per exported verb spelled as in C, and enums mirroring the C enums as enum.IntEnum classes built from the C name functions, never strings.
  • The receiver chooses, the verb stays. The model runs a verb on the calling thread, on(executor) blocks on an executor, and deferred(executor) submits it, all with the same arguments.
  • Deferred calls use the language’s own idioms. status polls through uform_outcome_status, wait blocks through uform_outcome_wait, and await hands wait() to the running event loop’s default executor.
  • No life of its own. The binding starts no threads and keeps no queues or caches; releasing a Deferred rides reference counting, which waits for the call first.
  • Arenas are lent and reused, never shared. Every output verb takes an arena and answers views borrowing it; an exported buffer pins its arena until released, and a view over a rewound one refuses to be read.
  • Nothing costs anything until it is used. Blocking calls take no deferred-table entry, a surface outputs leaves out is never computed, and an arena allocates only when a call writes into it.
  • Blocking calls stay as simple as the language allows. model.text_encode(texts, arena) takes no executor, completion or receiver argument and returns its result.
  • Suites run against the stub library, and against the real one with the tiny checkpoint UFORM_TEST_CHECKPOINT names.