The Dtype class is tsb's immutable, singleton type descriptor
— mirroring pandas' dtype hierarchy with 16 built-in types covering
integers, floats, booleans, strings, datetimes, and more.
Edit any code block below and press ▶ Run
(or Ctrl+Enter) to execute it live in your browser.
Obtain dtype instances via Dtype.from() or use the static singletons.
Identity comparison (===) works because every dtype is a cached singleton.
Each dtype exposes boolean predicates for its classification —
isNumeric, isInteger, isFloat, and more.
The itemsize property returns the byte width of each element.
Variable-length types (string, object, category) return 0.
Use canCastTo() to check safe promotion rules — whether values
of one dtype can be losslessly represented in another.
Dtype.commonType() finds the smallest dtype that can represent
both inputs without loss. Falls back to object when no numeric
promotion exists.
Dtype.inferFrom() auto-detects the most specific dtype from
an array of values — booleans, integers, floats, dates, strings, or mixed.
Write your own tsb code below. All exports from tsb are available:
Dtype, Series, Index, and more.