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)"
Even this takes only 3.5ms on the "task clock", counting all interpreter start-up time, bytecode compilation, etc: 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
"
(oops, that example changed to python2.7; python3.5 is a bit slower at 9ms)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.
Still, a toy language focusing on a particular benchmark can most likely easily beat any other high-level 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.