Python performance: it’s not just the interpreter
for reference, a pure java version through JMH that takes 0.38 seconds on my machine. This uses parallel stream so its multithreaded.<p>Single threaded it takes 0.71 seconds. Removing the blackhole to allow dead code elimination takes single thread down to 0.41 seconds. This is close to PyPy, which I assume is dead code eliminating the string conversion as well.<p><pre><code>    package org.example;

    import org.eclipse.collections.api.block.procedure.primitive.IntProcedure;
    import org.eclipse.collections.impl.list.Interval;
    import org.openjdk.jmh.annotations.Benchmark;
    import org.openjdk.jmh.infra.Blackhole;
    
    public class MyBenchmark {
    
      @Benchmark
      public void testMethod(final Blackhole blackhole) {
        Interval.oneTo(20)
            .parallelStream().forEach((IntProcedure)
                outer -&gt;
                    Interval.oneTo(1000000)
                        .forEach(
                            (IntProcedure)
                                inner -&gt;
                                    &#x2F;&#x2F; prevent dead code elimination
                                    blackhole.consume(Integer.toString(inner))));
      }
    }</code></pre>