ANN: Dogelog Runtime, Prolog to the Moon (2021)

Mostowski Collapse janburse at fastmail.fm
Wed Sep 15 12:23:10 EDT 2021


I really wonder why my Python implementation
is a factor 40 slower than my JavaScript implementation.
Structurally its the same code.

You can check yourself:

Python Version:
https://github.com/jburse/dogelog-moon/blob/main/devel/runtimepy/machine.py

JavaScript Version:
https://github.com/jburse/dogelog-moon/blob/main/devel/runtime/machine.js

Its the same while, if-then-else, etc.. its the same
classes Variable, Compound etc.. Maybe I could speed
it up by some details. For example to create an array
of length n, I use in Python:

   temp = [NotImplemented] * code[pos]
   pos += 1

Whereas in JavaScript I use, also
in exec_build2():

   temp = new Array(code[pos++]);

So I hear Guido doesn't like ++. So in Python I use +=
and a separate statement as a workaround. But otherwise,
what about the creation of an array,

is the the idiom [_] * _ slow? I am assuming its
compiled away. Or does it really first create an
array of size 1 and then enlarge it?

Julio Di Egidio wrote:
> On Wednesday, 15 September 2021 at 15:37:19 UTC+2, Mostowski Collapse wrote:
> 
>>> Opinion: Anyone who is counting on Python
>>> for truly fast compute speed is probably using
>>> Python for the wrong purpose.
> 
> You just don't know anything about this environment: those who need fast computation rather use *libraries* where all the performance critical parts are written in native code... and that's pretty customary in Python.
> 
> By that I don't mean Python is flawless, indeed (IMO) it isn't in so many ways: to the point that, for more professional solutions in the maths/statistics realms in particular, people rather use R: yet, the primary reason is not so much performance but really the solidity/structure of the language per se...
> 
> Julio
> 



More information about the Python-list mailing list