Post Reply 
Python Speed
04-29-2024, 09:52 PM
Post: #8
RE: Python Speed
(04-21-2021 03:14 PM)robve Wrote:  
(04-21-2021 07:34 AM)toml_12953 Wrote:  The new Python interpreter graphics are fast!

I ran three programs to draw a green hat, Here are the runtimes:

HPPL: 7.793 sec
CAS with Python syntax: 25.436 sec
Python (Apr 16 Beta): 0.926 sec

Very nice. My PRIME G2 takes even a bit longer, about 8.2 seconds to run the HPPL program.

I've used the following code, which I've translated to HPPL from the CAS Python code:

EXPORT pyhat()
  T:=TICKS; // Save the current clock count for timing program
  // Black out background
  // Start program proper
  P:=160; Q:=120;
  XP:=144; XR:=1.5*3.1415927;
  YP:=56; YR:=1; ZP:=64;
      ZT:=ZI*XP/ZP; ZZ:=ZI;
      // Draw one cross-section of figure
        XT:=sqrt(XI*XI+ZT*ZT)*XF; XX=XI;
        IF Y1!=0 THEN
          Line_p(X1,230-Y1+1,X1,230); // Erase points below current point
  // Wait for key and print elapsed time
  PRINT((T/1000)+" seconds");

Not sure if the PRIME Python graphics library internals are any different. The Python interpreter presumably uses the hardware floating point support of the Cortex-A7. The fp performance of Python on the HP PRIME is incredibly good: (translated in English with Google translate):

"The HP Prime are really extraordinary in floating point calculation Python and the HP Prime G2 even crushes all competition with its omnipotence, even by doping the latter with overclocking! Both among the solutionsPython official and solutions Python compatible with exam mode, HP Prime G2 is clearly the most powerful either in integer or in floating point calculus, and by far, congratulations!"

Even faster than "doping the competition with overclocking"... Wink

- Rob

Thanks Rob for the HPPL code !!
Although 3 minor changes are needed for those who are interested to try it out:
- replace int() with IP(), since int() is an integral function
- replace XX=XI with XX:=XI, just a typo
- replace FREEZE with WAIT(), not sure why FREEZE didn't wait for a key press
or else I get no hat or a 2d hat Smile

I need to develop a HP Prime program to use for work related tasks and I have been thinking about Python after many years from HP-25 to HP48*/HP-50. Smile
I ran both Python hat program from Tom (3s) and HPPL hat program from Rob (25s) on the HP Prime G1 and the HPPL version produced a lot more detailed plot for some reason ?? although the 2 codes looks very similar line by line. If anybody knows why the Python vs HPPL hat plots resolution are so different please post your finding here. This might have contributed to the significant additional execution time with HPPL.

Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
Python Speed - toml_12953 - 04-21-2021, 07:34 AM
RE: Python Speed - robmio - 04-21-2021, 12:05 PM
RE: Python Speed - toml_12953 - 04-21-2021, 01:46 PM
RE: Python Speed - robve - 04-21-2021, 03:14 PM
RE: Python Speed - txdinh - 04-29-2024 09:52 PM
RE: Python Speed - komame - 05-02-2024, 06:44 AM
RE: Python Speed - txdinh - 05-02-2024, 11:24 AM
RE: Python Speed - Xorand - 04-21-2021, 05:10 PM
RE: Python Speed - toml_12953 - 04-22-2021, 06:26 PM
RE: Python Speed - Guenter Schink - 04-22-2021, 06:41 PM
RE: Python Speed - txdinh - 05-02-2024, 12:20 AM

User(s) browsing this thread: 1 Guest(s)