Host
Intel Core Ultra 9 285K · 24 cores
Platform
linux/amd64
Go
go1.27.0
CPython
python:3.14-slim
PyPy
pypy:3.11-slim
Runs / combo
7 + 2 warmup

Type switches

Walk 100k heterogeneous values and dispatch by runtime type. Tests the type-assertion / type-switch path.

Runtime · median per inner-loop window

median of 7 runs

Native Gocompiled
645 µs0.01×
Pipitbytecode VM
50.3 msbaseline
CPython 3.14bytecode VM
125 ms2.49×
PyPy 7.3tracing JIT
28.9 ms0.57×
Ttengobytecode VM
125 ms2.49×
Sscriggobytecode VM
111 ms2.21×
Mmvmbytecode VM
152 ms3.01×
YyaegiAST walker
239 ms4.75×

Full statistics

RunnerNCompileRuntimeP95StddevRSSvs pipitStatus
Native Gocompiled7108 ms645 µs664 µs9.60 µs1.62 GiB0.01×OK
Pipitbytecode VM71.60 ms50.3 ms50.7 ms282 µs592 MiB1.00×OK
CPython 3.14bytecode VM7498 µs125 ms126 ms476 µsn/a2.49×OK
PyPy 7.3tracing JIT7372 µs28.9 ms33.7 ms2.05 msn/a0.57×OK
tengobytecode VM7263 µs125 ms142 ms6.45 ms1.69 GiB2.49×OK
scriggobytecode VM7558 µs111 ms120 ms3.79 ms1.69 GiB2.21×OK
mvmbytecode VM7449 µs152 ms154 ms1.21 ms1.69 GiB3.01×OK
yaegiAST walker7396 µs239 ms259 ms10.1 ms1.69 GiB4.75×OK
Workload & symmetry rules

Workload

Build a slice of 100,000 heterogeneous values mixing *IntVal, *StringVal, *BytesVal, *BoolVal, and *FloatVal. Walk the slice; for each value, dispatch by runtime type:

  • *IntVal → (v + 1234) & 0xFFFFFFFF
  • *StringVal → fnv1a32(v)
  • *BytesVal → XOR-fold of bytes
  • *BoolVal → 0 or 1
  • *FloatVal → uint32(v) & 0xFFFFFFFF

XOR every result into a uint32 accumulator.

Symmetry rules

  • Go uses a real switch v := v.(type) block; Python uses isinstance(...) if/elif equivalents.
  • No virtual method on the values themselves (that would be bench 13).

Why this benchmark exists

Distinct path from virtual dispatch and from generic dispatch. Measures the cost of runtime type discrimination in a hot loop.

Source code