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.

Runtime · median per inner-loop window

median of 10 runs

Native Gocompiled
567 µs0.01×
Piko interpbytecode VM
75.1 msbaseline
CPython 3.13bytecode VM
130 ms1.73×
PyPy 7.3tracing JIT
26.9 ms0.36×
Ttengobytecode VM
153 ms2.04×
Sscriggobytecode VM
127 ms1.70×
Mmvmbytecode VM
146 ms1.94×
YyaegiAST walker
317 ms4.22×

Full statistics

RunnerNCompileRuntimeP95StddevRSSvs pikoStatus
Native Gocompiled10182 ms567 µs605 µs15.0 µs69 MiB0.01×OK
Piko interpbytecode VM101.53 ms75.1 ms96.8 ms6.52 ms151 MiB1.00×OK
CPython 3.13bytecode VM10434 µs130 ms131 ms1.98 msn/a1.73×OK
PyPy 7.3tracing JIT10365 µs26.9 ms31.0 ms1.38 msn/a0.36×OK
tengobytecode VM10307 µs153 ms160 ms2.78 ms1.49 GiB2.04×OK
scriggobytecode VM10490 µs127 ms132 ms1.89 ms908 MiB1.70×OK
mvmbytecode VM10403 µs146 ms168 ms9.84 ms67 MiB1.94×OK
yaegiAST walker10523 µs317 ms345 ms19.6 ms78 MiB4.22×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