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

2021-09-15 Thread Chris Angelico
On Thu, Sep 16, 2021 at 7:59 AM Mostowski Collapse wrote: > > BTW: I could already make it faster, by not repeatedly > accessing .arg anymore. It went down from ca.: > > 171'000 ms > > To this here: > > 140'000 ms > > But only in the cold run. In the warm run it went back > to 171'000 ms. Possibly

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

2021-09-15 Thread Mostowski Collapse
Thank you for the suggestion. The test harness is invoked as follows. So it does already do time/1, thats also how I did the comparison Standard Python and GraalVM Python, a file dogelog.py: import sys # sys.path.append("\jekrun_bench\core\harness2\libpy") sys.path.append("/mnt/c//jekrun_bench/c

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

2021-09-15 Thread Mostowski Collapse
BTW: I could already make it faster, by not repeatedly accessing .arg anymore. It went down from ca.: 171'000 ms To this here: 140'000 ms But only in the cold run. In the warm run it went back to 171'000 ms. Possibly when my code is faster, it will create objects more faster, and kill the Pytho

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

2021-09-15 Thread Mostowski Collapse
Ok you suggested: >>>items = [1,2,3,4,5,6,7,8,9,0] >>>for item in items[:-1]: >>> print(item) 1 2 3 4 5 6 7 8 9 Does this also work for length = 1? Ok let me try: >>> foo = ["a","b","c"] >>> for x in foo[:-1]: ... print(x) ... a b >>> foo = ["a"] >>> for x in foo[:-1]: ... print(x) ...

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

2021-09-15 Thread DFS
On 9/15/2021 5:10 PM, Mostowski Collapse wrote: And how do you only iterate over n-1 elements? I don't need a loop over all elements. With array slicing? Someting like: for item in items[0:len(items)-2]: ___print(item) Or with negative slicing indexes? Problem is my length can be equal to one

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

2021-09-15 Thread Mostowski Collapse
And how do you only iterate over n-1 elements? I don't need a loop over all elements. With array slicing? Someting like: for item in items[0:len(items)-2]: ___print(item) Or with negative slicing indexes? Problem is my length can be equal to one. And when I have length equal to one, the slic

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

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 11:56:47 -0700, Mostowski Collapse wrote: > What could be slow, repeatedly requesting the "args" > field. Maybe I should do: > > help = term.args i = 0 while i < len(help) - 1: > mark_term(help[i]) > i += 1 term = help[i] > No this construct is a common error in new p

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

2021-09-15 Thread DFS
On 9/15/2021 12:23 PM, Mostowski Collapse wrote: 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

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

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 11:48:18 -0700, Mostowski Collapse wrote: > And how do you iterate over the first n-1 elements of a list with n > elements? This is what my code does: > > i = 0 while i < len(term.args) - 1: > mark_term(term.args[i]) > i += 1 term = term.args[i] > > You can try yourse

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

2021-09-15 Thread Mostowski Collapse
But the end-result is still very weak: % Wall 33810 ms, gc 980 ms, 284108 lips This is below 1 million LIPS. The JavaScript version of Dogelog does currently around 2 million LIPS. And SWI-Prolog can do around 20 million LIPS. Mostowski Collapse schrieb am Mittwoch, 15. September 2021 um 23:29

Re: The code version of python -i

2021-09-15 Thread Abdur-Rahmaan Janhangeer
Thanks folks will update with progress soon > -- https://mail.python.org/mailman/listinfo/python-list

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

2021-09-15 Thread Mostowski Collapse
What could be slow, repeatedly requesting the "args" field. Maybe I should do: help = term.args i = 0 while i < len(help) - 1: mark_term(help[i]) i += 1 term = help[i] Mostowski Collapse schrieb am Mittwoch, 15. September 2021 um 20:48:31 UTC+2: > And how do you iterate over the first n-

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

2021-09-15 Thread Chris Angelico
On Thu, Sep 16, 2021 at 5:15 AM Mostowski Collapse wrote: > > If you find a "wonky" spot, I can replace it by "non-wonky" > code. I noticed some differences between Python Dicts > and JavaScript objects. Python tends to throw more exceptions. > > So in Python I now do the following: > >peek =

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

2021-09-15 Thread Mostowski Collapse
There is a Python 3.8 compatible version here: https://github.com/jburse/dogelog-moon/blob/main/devel/runtimepy/machine2.py I have replaced match by if-then-else. So as to be able to test with GraalVM. GraalVM is still faster despite using if-then-else. But GraalVM needs some time to JIT the cod

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

2021-09-15 Thread Mostowski Collapse
And how do you iterate over the first n-1 elements of a list with n elements? This is what my code does: i = 0 while i < len(term.args) - 1: mark_term(term.args[i]) i += 1 term = term.args[i] You can try yourself: % python3 >>> foo = ["a", "b", "c"] >>> i = 0 >>> while i < len(foo) - 1:

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

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 18:40:52 +, alister wrote: > On Wed, 15 Sep 2021 11:31:48 -0700, Mostowski Collapse wrote: > >> There is a further problem with this: >> >>> for i,term in enumerate(term.args): >>> mark_term(term.args[i]) >> >> It should read: >> >> for i,help in enumerate(term.args

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

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 11:31:48 -0700, Mostowski Collapse wrote: > There is a further problem with this: > >> for i,term in enumerate(term.args): >> mark_term(term.args[i]) > > It should read: > > for i,help in enumerate(term.args): > mark_term(help) > > But then i isn't need. even Better

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

2021-09-15 Thread Mostowski Collapse
There is a further problem with this: > for i,term in enumerate(term.args): > mark_term(term.args[i]) It should read: for i,help in enumerate(term.args): mark_term(help) But then i isn't need. Mostowski Collapse schrieb am Mittwoch, 15. September 2021 um 20:22:50 UTC+2: > Do you me

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

2021-09-15 Thread Mostowski Collapse
Well I would be more than happy if an experienced programmer can fine tune my code. My programming experience in Python is only 4 weeks. Mostowski Collapse schrieb am Dienstag, 14. September 2021 um 14:56:35 UTC+2: > The test harness, test cases and individual > results for all test cases are fou

Re: The code version of python -i

2021-09-15 Thread Dennis Lee Bieber
On Wed, 15 Sep 2021 16:08:32 +0200, Peter Otten <__pete...@web.de> declaimed the following: > >I tried > >import code > >x = 42 >code.interact(local=globals()) > >but didn't bother to read the documentation at > >https://docs.python.org/3/library/code.html > >and thus do not know what the limitati

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

2021-09-15 Thread Mostowski Collapse
Do you mean, replace this: i = 0 while i < len(term.args) - 1: mark_term(term.args[i]) i += 1 term = term.args[i] By this: for i,term in enumerate(term.args): mark_term(term.args[i]) This wouldn't be correct anymore. The recursive call is only for the arguments except for the last

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

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 18:23:10 +0200, Mostowski Collapse wrote: > 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/

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

2021-09-15 Thread alister via Python-list
On Thu, 16 Sep 2021 03:26:39 +1000, Chris Angelico wrote: > On Thu, Sep 16, 2021 at 3:17 AM Mostowski Collapse > wrote: >> >> I really wonder why my Python implementation is a factor 40 slower than >> my JavaScript implementation. >> Structurally its the same code. >> >> > Very hard to know. Your

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

2021-09-15 Thread Mostowski Collapse
If you find a "wonky" spot, I can replace it by "non-wonky" code. I noticed some differences between Python Dicts and JavaScript objects. Python tends to throw more exceptions. So in Python I now do the following: peek = kb.get(functor, NotImplemented) if peek is not NotImplemented:

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

2021-09-15 Thread Chris Angelico
On Thu, Sep 16, 2021 at 3:17 AM Mostowski Collapse wrote: > > I really wonder why my Python implementation > is a factor 40 slower than my JavaScript implementation. > Structurally its the same code. > Very hard to know. Your code is detailed and complicated. Do they produce identical results? Ar

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

2021-09-15 Thread Mostowski Collapse
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

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

2021-09-15 Thread Mostowski Collapse
Oops "speed did never hurt anybody". Don't be evil, I am talking about unarmed drones. See also: Drone Programming With Python Course https://www.youtube.com/watch?v=LmEcyQnfpDA Mostowski Collapse schrieb: I am not testing this use-case. But a related use-case might highlight why speed did nev

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

2021-09-15 Thread Mostowski Collapse
I am not testing this use-case. But a related use-case might highlight why speed did never hurt anybody. Lets say you program a flying drone with Python, and the measurement is from the drone sensor and communication systems. Lets say you are using the idle time between measurements for some com

Re: The code version of python -i

2021-09-15 Thread Peter Otten
On 15/09/2021 15:39, Abdur-Rahmaan Janhangeer wrote: Greetings, If i have a file name flower.py and i add x = 1 in it. When i run python -i flower.py i get a shell If type x i get 1 x 1 The values are auto injected. How do i start a shell by code with values already injected? Thanks Kin

The code version of python -i

2021-09-15 Thread Abdur-Rahmaan Janhangeer
Greetings, If i have a file name flower.py and i add x = 1 in it. When i run python -i flower.py i get a shell >>> If type x i get 1 >>> x 1 The values are auto injected. How do i start a shell by code with values already injected? Thanks Kind Regards, Abdur-Rahmaan Janhangeer about