BIPLAN looks to be 1370 times faster than Python
github.comBIPLAN: https://github.com/gioblu/BIPLAN is a programming language, which comes with its own virtual machine and its compiler. It is really simple and it is an early protototype, although benchmarking it looks astonishingly quicker than other interpreted programming languages like python. How can be 3 orders of magnitude quicker than python? O_O
It seems likely you're measuring something other than what you intended to measure, like the start-up time of the Python interpreter, time to byte-compile Python source, etc. fib(40) itself runs in 1.1us/loop on this Ryzen 3700X running Debian Buster and Python 3.7.3, excluding start-up costs using timeit:
Even this takes only 3.5ms on the "task clock", counting all interpreter start-up time, bytecode compilation, etc:python3 -mtimeit -s" def fib(x): a = 0 b = 1 for i in range(x): a, b = a+b, a return a assert fib(40) == 102334155 " "fib(40)"
(oops, that example changed to python2.7; python3.5 is a bit slower at 9ms)perf stat python -S -c " def fib(x): a = 0 b = 1 for i in range(x): a, b = a+b, a return a assert fib(40) == 102334155 "Also, give fib(48) a try. Python will switch to bigint, but (https://github.com/gioblu/BIPLAN/blob/master/documentation/n...):
BIPLAN supports only one numeric variable type that is by default int32_t
So, fib(48) will overflow, and probably will return a negative number.
Preferring to give the right answer over giving an answer fast is one of the design decisions Python made.
There also is the unconventional choice to use a global array to store variables, leading to “BIPLAN supports a maximum amount of 116 global variables”. I don’t think changing that to make it growable will affect speed much, though.
Well, Python is not known for its speed (even among established interpreted languages), and a couple of design choices make it have a pretty heavy overhead.
Still, a toy language focusing on a particular benchmark can most likely easily beat any other high-level language.
>Still, a toy language...
Not sure what is the effective definition of "toy language".
>...focusing on a particular benchmark can most likely easily beat any other high-level language.
I was just curious to understand the performance difference so I have tried fib(40) on both BIPLAN and python side.
How can python be THAT slow? It is a huge waste of energy and people's time.