Post Reply 
HP_PRIME PYTHON SYNTAX: HP_PPY
11-12-2017, 03:59 PM (This post was last modified: 11-13-2017 12:39 PM by compsystems.)
Post: #1
HP_PRIME PYTHON SYNTAX: HP_PPY




We need an updated primePAD of primeComn. (external program editor), the coding and tabulation is very difficult inside the small screen 240*320_pxls

[Image: Image%202014-03-31%20at%202.58.49%20PM.png]

some enthusiast what continues the development of primePAD
Source code and info: >
http://www.hpmuseum.org/forum/thread-36....t=primepad
.

LO SUFICIENTEMENTE BUENO ES ENEMIGO DE LA EXCELENCIA.
Find all posts by this user
Quote this message in a reply
11-12-2017, 04:42 PM
Post: #2
RE: HP_PRIME PYTHON: HP_PPY
(11-12-2017 03:59 PM)compsystems Wrote:  



We need an updated primePAD. (external program editor)


.

So where can we get Python for Prime?

Tom L
I think therefore I am-Descartes
I think therefore you are-Gorgias
You're not here to think-Army Sergeant
Find all posts by this user
Quote this message in a reply
11-12-2017, 05:58 PM
Post: #3
RE: HP_PRIME PYTHON: HP_PPY
I think the language is in the new beta and it's limited....I don't know if the docs exist yet.
I'd also like to know is it compiled like HPPL or what? i.e. Is it as fast as HPPL?
Find all posts by this user
Quote this message in a reply
11-12-2017, 06:08 PM
Post: #4
RE: HP_PRIME PYTHON: HP_PPY
Speed test only with FOR loop and exponent


Attached File(s)
.hpprgm  CAS-Python-HPPPL.hpprgm (Size: 2.05 KB / Downloads: 54)

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
11-12-2017, 06:12 PM
Post: #5
RE: HP_PRIME PYTHON: HP_PPY
I just tried that on the virtual prime on my PC and it says the Python is faster than HPPL is faster than CAS. I know it's a limited test, but it's still encouraging....
Find all posts by this user
Quote this message in a reply
11-12-2017, 06:19 PM
Post: #6
RE: HP_PRIME PYTHON: HP_PPY
The times of CAS and "Python" should be similar, with respect to the tests per loop it is inconsistent when varies the variable a=10 000, 50 000, 100 000, 500 000

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
11-12-2017, 06:21 PM
Post: #7
RE: HP_PRIME PYTHON: HP_PPY
I take that back. I noticed that the test ran for under a second and I remembered that you really need to run for a few seconds to get an accurate evaluation, so I increased the iteration count by 100, and get:

CAS = 21.5 s
Python = 18.5 s
HPPL = 14.5 s

...which is more in line with what I'd expect....i.e. HPPL is faster than python.
Find all posts by this user
Quote this message in a reply
11-12-2017, 06:26 PM
Post: #8
RE: HP_PRIME PYTHON: HP_PPY
I still believe that CAS = "Python" xD

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
11-12-2017, 07:35 PM (This post was last modified: 11-12-2017 07:39 PM by parisse.)
Post: #9
RE: HP_PRIME PYTHON: HP_PPY
It's not Python, it's Python syntax compatibility inside CAS. I wrote a pre-parser that translates Python-like indentation to CAS blocs: def/for/while/if/else -> function/for/while/if/else
There are differences with true Python: only basic Python syntax is supported (no class or generators for example), string delimiters must be " (' keeps the same meaning that in normal CAS programs), there is no module import, but you have access to all CAS commands. It is recommended to declare local variables, the current implementation of the pre-parser will leave undeclared variables as global. List indexes follow HP convention on the Prime (start at 1). The programming editor of the Prime does not support this syntax, therefore it's not easy to program on the calc with Python syntax.
The interpreter behind is the CAS interpreter, therefore it should run at the same speed, and this is in general slower than the Home interpreter, there is a price to pay for more types (exact types, symbolic expressions, but also functions that can be passed as arguments to functions). There are a few optimizations in the CAS interpreter in this beta version, they will work if the variables used in the loops are local variables (and loops are a little faster if they contain only 1 instruction), another reason to declare local variables with the local keyword (something that you can not do in Python).
Find all posts by this user
Quote this message in a reply
11-12-2017, 11:27 PM
Post: #10
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
To be blunt, I would not recommend using this at this time. It will work, but the tools and editors are not set up to support it.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
11-13-2017, 12:10 AM
Post: #11
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
Good evening dear parisse I write to you from my country Peru,
as much respect and I already ask for my apologies if uncomfortable with my comment I would like to say what
following:
   1. I find it unnecessary to put that basic Python syntax in HPPPL for me is to waste time should worry about other issues as I will mention in the lines below.
  2._ They should worry about releasing a way to protect the programs in HPPPL, I mentioned this topic because where I live according to conversations with my friends (by the way they are good programmers), they do not want to share their programs or publish for the theme of the piracy, then I think you should worry about that issue, because if they do not lose Hp Prime users, because others still prefer 50G and we know it is obsolete, but they prefer it because they have many programs that HP PRIME.
  3._Well, it's just an opinion that the HP PRIME team is losing time doing unnecessary things because HPPPL is enough.



Buenas noches estimado parisse le escribo desde mi país Perú,
como mucho respeto y ya pido mis disculpas si incómodo con mi comentario quisiera decir lo
siguiente:
1._Me parece innecesario que pongan esa sintaxis básica de Python en HPPPL para mi es perder tiempo deben preocuparse en otros temas como voy mencionar en líneas abajo.
2._ Deben preocuparse en liberar una forma de proteger los programas en HPPPL, le mencionó este tema porque por donde vivo según conversaciones con mis amigos (por cierto que son buenos programadores), no quieren compartir sus programas o publicar por el tema de la piratería, entonces pienso deben preocuparse en ese tema, ya que si no lo hacen van perder usuarios de Hp Prime , porque otros siguen prefiriendo 50G y sabemos es obsoleto, pero lo prefieren porque tienen muchos programas que HP PRIME.
3._Bueno es solo una opinión recalco pierden tiempo el equipo de HP PRIME haciendo cosas innecesarias porque HPPPL es suficiente.
Find all posts by this user
Quote this message in a reply
11-13-2017, 08:55 AM
Post: #12
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
To make it clear, the Python syntax compatibility is not something HP has decided to do (and that explains that there is no UI support for that), it is a feature that I have decided to implement for Giac/Xcas because there is an important change in the highschool curriculum in France, and it seems that a lot of teachers will switch to Python. They will be more comfortable to use Xcas if they can program with the same control structures. Now, I also believe it could be a real plus once integrated in the HP programming editor UI. In the mean time, you can program in Python with your favorite UI on your PC, check that it works with Xcas for Firefox and then transfer to the calc.
Find all posts by this user
Quote this message in a reply
11-13-2017, 12:03 PM
Post: #13
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
I do agree with incorporating python syntax, it is the fastest growing language, more than java and others, python has an air of RPN commands

I am not in agreement with protecting programs, for that they are other platforms, the purpose of the hp / prime is the education, not the commerce, therefore all program focused for the education to be free, of free distribution and open code.

[Image: 1366_2000.png]

[Image: 1366_2000.png]

LO SUFICIENTEMENTE BUENO ES ENEMIGO DE LA EXCELENCIA.
Find all posts by this user
Quote this message in a reply
11-13-2017, 12:09 PM
Post: #14
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
most of python things are due beginners trying things out. It does not matter the language if one wants to do something serious.

As one learns python one can learn HPPL or whathever. Moreover without the possibility to integrate the common python libraries, having only the syntax is just cosmetics. Therefore I fully understand the approach of Mr. parisse to cover school curriculums.

But this is misunderstood by those that don't produce actual code.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
11-13-2017, 12:19 PM (This post was last modified: 11-13-2017 12:47 PM by compsystems.)
Post: #15
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
Another video





[Image: EOKvxidt.png]
[Image: bJDic5Ft.png]

PHP Code:
#cas
 
def fractale(X,Y,N) :
 
local x,y,z,c,j,t
 
for x in range(X):
  for 
y in range(Y):
   
z=0
   c
=2.7x/X-2.1-i*(1.87y/Y-.935)
   
j=-1
   
while((j=j+1)
   
z=z*z+c
   t
=255j/N
   PIXON_P
(x,y,RGB(IP(t),IP(3t/4),IP(t/4)))
 
FREEZE
 WAIT
(0)
#end 

What is the equivalent code in Xcas language?



.

LO SUFICIENTEMENTE BUENO ES ENEMIGO DE LA EXCELENCIA.
Find all posts by this user
Quote this message in a reply
11-13-2017, 04:16 PM
Post: #16
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
You did not copy the code correctly. You will get the translation if you do a copy/paste in a recent version of Xcas (the translation of the pre-parser is displayed so that syntax error are meaningfull).
Find all posts by this user
Quote this message in a reply
11-13-2017, 05:01 PM
Post: #17
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-13-2017 12:09 PM)pier4r Wrote:  most of python things are due beginners trying things out. It does not matter the language if one wants to do something serious.

As one learns python one can learn HPPL or whathever. Moreover without the possibility to integrate the common python libraries, having only the syntax is just cosmetics. Therefore I fully understand the approach of Mr. parisse to cover school curriculums.

But this is misunderstood by those that don't produce actual code.

I don't see the point in just having some of the syntax the same (then again, I don't go to school in France!) I'd love a real, full Python implementation for the Prime but just including some of the syntax elements doesn't do anything for me.

Tom L
I think therefore I am-Descartes
I think therefore you are-Gorgias
You're not here to think-Army Sergeant
Find all posts by this user
Quote this message in a reply
11-13-2017, 05:46 PM
Post: #18
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
You just need a small subset of Python to run French highschool programs, then it's easy to provide full integration in the calculator, I don't think you can have a full Python that is interoperable with the calculator without very very large changes. And I'm going to add an optionnal feature that I think is useful in an educational context and is not available in Python: declare variable type, and check at sto.
Find all posts by this user
Quote this message in a reply
11-13-2017, 07:32 PM
Post: #19
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-13-2017 05:46 PM)parisse Wrote:  You just need a small subset of Python to run French highschool programs, then it's easy to provide full integration in the calculator, I don't think you can have a full Python that is interoperable with the calculator without very very large changes.

A few people are working on replacement firmware for the Prime (non-HP, of course). I'd gladly give up HPPL, CAS or both for a full Python interpreter.

Tom L
I think therefore I am-Descartes
I think therefore you are-Gorgias
You're not here to think-Army Sergeant
Find all posts by this user
Quote this message in a reply
11-13-2017, 09:07 PM
Post: #20
RE: HP_PRIME PYTHON SYNTAX: HP_PPY
(11-13-2017 07:32 PM)toml_12953 Wrote:  course). I'd gladly give up HPPL, CAS or both for a full Python interpreter.

I assume you mean "full, standard python" not tiny python or any of the more restricted ones. Would you accept no having C bindings? Would you give up any possibility to interact with the HP math routines and all CAS functions as part of that trade?

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
Post Reply 




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