def fields_of(memo_type: type) -> FieldNamespace
Open SourceStandard
Return a namespace of first-class field references for a dbzero memo type.
Field references identify memo fields for APIs such as
db0.index_of(...). They do not read or write instance values,
and they do not replace normal Python class attributes.
fields = db0.fields_of(Task)
priority_field = fields.priority
priority_index = db0.index_of(priority_field)Parameters
memo_typetype
A dbzero memo class.
Returns
A FieldNamespace bound to the memo type.
Attribute Lookup
Use attribute lookup for known field declarations. This is the preferred syntax for indexed fields:
priority = db0.index_of(db0.fields_of(Task).priority)Attribute lookup is strict. Unknown names raise AttributeError, which helps
catch typos early.
For dataclasses, fields_of preserves normal class-attribute behavior:
from dataclasses import dataclass
@db0.memo
@dataclass
class Task:
title: str
priority: int = 0
assert Task.priority == 0
assert db0.fields_of(Task).priority is db0.fields_of(Task).priorityDynamic Field Names
Use subscription when the field name is dynamic or not a valid Python attribute:
field_name = "priority"
priority_field = db0.fields_of(Task)[field_name]
keyword_field = db0.fields_of(Task)["from"]Subscription accepts persistent field names and returns a FieldRef. The
consuming API, such as db0.index_of(...), validates whether that field is
valid for the requested operation.
Notes
fields_ofaccepts memo types, not instances.- Field references are process-local objects, not durable values.
- A
FieldRefcan be compared and hashed, but it is not a descriptor and is not installed on the memo type. fields_ofdoes not open a prefix or materialize a field by itself.