tsb — Dtype Playground
🔢 Dtype — Interactive Playground
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.
Creating Dtypes
Obtain dtype instances via Dtype.from() or use the static singletons.
Identity comparison (===) works because every dtype is a cached singleton.
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent
Kind Classification
Each dtype exposes boolean predicates for its classification —
isNumeric, isInteger, isFloat, and more.
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent
Item Sizes
The itemsize property returns the byte width of each element.
Variable-length types (string, object, category) return 0.
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent
Type Casting
Use canCastTo() to check safe promotion rules — whether values
of one dtype can be losslessly represented in another.
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent
Common Type Resolution
Dtype.commonType() finds the smallest dtype that can represent
both inputs without loss. Falls back to object when no numeric
promotion exists.
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent
Type Inference
Dtype.inferFrom() auto-detects the most specific dtype from
an array of values — booleans, integers, floats, dates, strings, or mixed.
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent
🧪 Try It Yourself
Write your own tsb code below. All exports from tsb are available:
Dtype, Series, Index, and more.
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent