fdtdx.frozen_field

Contents

fdtdx.frozen_field#

fdtdx.frozen_field(*, default=null, init=True, repr=True, kind='KW_ONLY', metadata=None, on_setattr=(), on_getattr=(), alias=None)[source]#

Creates a field that automatically freezes on set and unfreezes on get.

This field behaves like a regular pytreeclass field but ensures values are frozen when stored and unfrozen when accessed.

Parameters:
  • default (Any, optional) – The default value for the field. Defaults to None.

  • init (bool, optional) – Whether to include the field in __init__. Defaults to True.

  • repr (bool, optional) – Whether to include the field in __repr__. Defaults to True.

  • kind (ArgKindType, optional) – The argument kind (POS_ONLY, POS_OR_KW, etc.). Defaults to KW_ONLY.

  • metadata (dict[str, Any] | None, optional) – Additional metadata for the field. Defaults to None.

  • on_setattr (Sequence[Any], optional) – Additional setattr callbacks (applied after freezing). Defaults to no callbacks.

  • on_getattr (Sequence[Any], optional) – Additional getattr callbacks (applied after unfreezing). Defaults to no callbacks.

  • alias (str | None, optional) – Alternative name for the field in __init__. Defaults to None

Returns:

A Field instance configured with freeze/unfreeze behavior

Return type:

Any