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.

Compile time · median (cold)

median of 7 runs

Native Gocompiled
108 ms67.3×
Pipitbytecode VM
1.60 msbaseline
CPython 3.14bytecode VM
498 µs0.31×
PyPy 7.3tracing JIT
372 µs0.23×
Ttengobytecode VM
263 µs0.16×
Sscriggobytecode VM
558 µs0.35×
Mmvmbytecode VM
449 µs0.28×
YyaegiAST walker
396 µs0.25×

Full statistics

RunnerNCompileRuntimeP95StddevRSSvs pipitStatus
Native Gocompiled7108 ms645 µs664 µs9.60 µs1.62 GiB67.3×OK
Pipitbytecode VM71.60 ms50.3 ms50.7 ms282 µs592 MiB1.00×OK
CPython 3.14bytecode VM7498 µs125 ms126 ms476 µsn/a0.31×OK
PyPy 7.3tracing JIT7372 µs28.9 ms33.7 ms2.05 msn/a0.23×OK
tengobytecode VM7263 µs125 ms142 ms6.45 ms1.69 GiB0.16×OK
scriggobytecode VM7558 µs111 ms120 ms3.79 ms1.69 GiB0.35×OK
mvmbytecode VM7449 µs152 ms154 ms1.21 ms1.69 GiB0.28×OK
yaegiAST walker7396 µs239 ms259 ms10.1 ms1.69 GiB0.25×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