Euler 21.6 and Python

Version 21.6 changes to the most recent Maxima version, which did not pose any problems. The trouble started when I tried to use Python as a script language.

For a first start, you can send commands to Python. The reply is collected in a Python string and that string is copied back to Euler. So the result of the python() command is a string. For commands over many lines, you can use a vector of strings. You can also load commands from a file.

It is interesting to observe the timings. The recursive Fibonacci test takes about 10 times longer than the C version, but it is about 10 times faster than the Euler version. This seems to be typical result. So, in terms of speed, the progress is not impressive. It is the flexibility, which attracts me.

The first version of 21.6 had problems with systems, where Python 2.7 is not installed. Euler could not be started then. Even if the basic Python DLL was provided in the Euler installation, Python would crash if it does not find its home directory. Worse, it calls exit() and aborts Euler. I found a solution to this via an intermittent DLL and a check on the existence of a Python installation. So, if you do not want to install Python, that is Okay with the rest of Euler.

The idea behind this is to go towards a true scripting option, where Euler functions can be called by Python and Python functions can be called by Euler. Since Python variables are typeless, the Python arguments can be translated into Euler elements on the fly, and the other way around. This is better than the C interface, which relies on strict parameter types.

2 Gedanken zu „Euler 21.6 and Python

  1. yp

    Have you ever considered Lua or LuaJIT as a scripting language? It is realy easy embeddable with very small footprint and fast (LuaJIT).

    1. mga010 Beitragsautor

      Thanks for the hint. I did not consider this. There might be other choices as well, which I did not consider.

      Python looks like a good choice because it is wide spread, mature, has a huge library and big support. I understand that Lua is easier to add, though the devil is in the details. It seems to be faster due to its stack orientation, if I am not mistaken. But one must carefully compare. And both cannot cope with C anyway.

      Lua has some attraction to me because it comes from Rio, a town I have enjoyed very much when I was there in 2008 (See). 🙂


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.