Host
Intel Core Ultra 9 285K · 24 cores
Platform
linux/amd64
Go
go1.26.0
CPython
python:3.13-slim
PyPy
pypy:3.10-slim
Runs / combo
10 + 2 warmup

Type switches

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

Compile time · median (cold)

median of 10 runs

Native Gocompiled
182 ms119×
Piko interpbytecode VM
1.53 msbaseline
CPython 3.13bytecode VM
434 µs0.28×
PyPy 7.3tracing JIT
365 µs0.24×
Ttengobytecode VM
307 µs0.20×
Sscriggobytecode VM
490 µs0.32×
Mmvmbytecode VM
403 µs0.26×
YyaegiAST walker
523 µs0.34×

Full statistics

RunnerNCompileRuntimeP95StddevRSSvs pikoStatus
Native Gocompiled10182 ms567 µs605 µs15.0 µs69 MiB119×OK
Piko interpbytecode VM101.53 ms75.1 ms96.8 ms6.52 ms151 MiB1.00×OK
CPython 3.13bytecode VM10434 µs130 ms131 ms1.98 msn/a0.28×OK
PyPy 7.3tracing JIT10365 µs26.9 ms31.0 ms1.38 msn/a0.24×OK
tengobytecode VM10307 µs153 ms160 ms2.78 ms1.49 GiB0.20×OK
scriggobytecode VM10490 µs127 ms132 ms1.89 ms908 MiB0.32×OK
mvmbytecode VM10403 µs146 ms168 ms9.84 ms67 MiB0.26×OK
yaegiAST walker10523 µs317 ms345 ms19.6 ms78 MiB0.34×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
  • *StringValfnv1a32(v)
  • *BytesVal → XOR-fold of bytes
  • *BoolVal0 or 1
  • *FloatValuint32(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