Hi Jon,

> to my surprise my Pico Lisp version was much slower than my Scala version.

You've hit upon an old problem. Conversion from internal to decimal
representation in PicoLisp takes too long. We had a similar discussion
here some time ago, initiated by Tomas Hlavaty.

You can see this easily if you look at the steps separately (I put a 'T'
at the end of each line to avoid the actual output of the big numbers):

   : (bench (** Big 300)) T
   0.049 sec
   -> T

This is very short in comparison to decimal formatting:

   : (bench (format (** Big 300))) T
   17.862 sec
   -> T

BTW, you can also directly 'chop' a number, without the need of
'format'ing it. But this won't change anything either:

   : (bench (chop (** Big 300))) T  
   17.814 sec
   -> T

Same goes for direct printing:

   : (bench (out "/dev/null" (println (** Big 300)))) T
   18.079 sec
   -> T

In all these cases, the final conversion took about 360 times longer
than the actual calculation.

> Could I have written the Pico Lisp code differently to make it faster?

Not the Lisp code, the conversion goes completely in the kernel. But I
have also no better idea how to do a decimal conversion faster.

- Alex
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to