Re: [pypy-dev] Newbie question: using PyPy to compile the source

of a single function? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c3715035453704dbec5495 --001a11c3715035453704dbec5495 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Doesn't PyPy have a "compile to binary" option? I thought it did, but I may be mistaken. Sent from my Windows Phone From: Phyo Arkar Sent: 5/4/2013 6:52 PM To: haoyi.sg@gmail.com Cc: pypy-dev@python.org Subject: Re: [pypy-dev] Newbie question: using PyPy to compile the source of a single function? Pypy is JIT. if you want to do such thing you better look for Nuitika and Cython. On Sun, May 5, 2013 at 5:02 AM, <haoyi.sg@gmail.com> wrote:
I=E2=80=99m looking for some way of programmatically using PyPy to compil= e a snippet of python source code (probably a function def) into an optimized binary, which I can call to pass data back and forth. The end goal is to have something like this
@PyPy def expensive_function(arg): ... expensive computation ... return result
using macros (https://github.com/lihaoyi/macropy) to perform this conversion at import time.
I have no idea if this is possible or not; could anyone here give me any pointers or advice how to do this/why it is impossible?
Thanks! -Haoyi
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev
--001a11c3715035453704dbec5495 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable <html><head><meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Cont= ent-Type"></head><body><div><div style=3D"font-family: Calibri,sans-serif; = font-size: 11pt;">Doesn't PyPy have a "compile to binary" option? I thought= it did, but I may be mistaken.<br><br>Sent from my Windows Phone<br></div>= </div><hr><span style=3D"font-family: Tahoma,sans-serif; font-size: 10pt; f= ont-weight: bold;">From: </span><span style=3D"font-family: Tahoma,sans-ser= if; font-size: 10pt;">Phyo Arkar</span><br><span style=3D"font-family: Taho= ma,sans-serif; font-size: 10pt; font-weight: bold;">Sent: </span><span styl= e=3D"font-family: Tahoma,sans-serif; font-size: 10pt;">5/4/2013 6:52 PM</sp= an><br><span style=3D"font-family: Tahoma,sans-serif; font-size: 10pt; font= -weight: bold;">To: </span><span style=3D"font-family: Tahoma,sans-serif; f= ont-size: 10pt;">haoyi.sg@gmail.com</span><br><span style=3D"font-family: T= ahoma,sans-serif; font-size: 10pt; font-weight: bold;">Cc: </span><span sty= le=3D"font-family: Tahoma,sans-serif; font-size: 10pt;">pypy-dev@python.org= </span><br><span style=3D"font-family: Tahoma,sans-serif; font-size: 10pt; = font-weight: bold;">Subject: </span><span style=3D"font-family: Tahoma,sans= -serif; font-size: 10pt;">Re: [pypy-dev] Newbie question: using PyPy to com= pile the source of a single function?</span><br><br></body></html><div dir= =3D"ltr">Pypy is JIT. if you want to do such thing you better look for Nuit= ika and Cython.</div><div class=3D"gmail_extra"><br><br><div class=3D"gmail= _quote">On Sun, May 5, 2013 at 5:02 AM, <span dir=3D"ltr"><<a href=3D"m= ailto:haoyi.sg@gmail.com" target=3D"_blank">haoyi.sg@gmail.com</a>></spa= n> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div><div style=3D"font-family:Calibri,'= Segoe UI',Meiryo,'Microsoft YaHei UI','Microsoft JhengHei U= I','Malgun Gothic','Khmer UI','Nirmala UI',Tung= a,'Lao UI',Ebrima,sans-serif;font-size:16px"> <div>I=E2=80=99m looking for some way of programmatically using PyPy to com= pile a snippet of python source code (probably a function def) into an opti= mized binary, which I can call to pass data back and forth. The end goal is= to have something like this</div> <div>=C2=A0</div><div>@PyPy</div><div>def expensive_function(arg):</div><di= v>=C2=A0=C2=A0=C2=A0=C2=A0... expensive computation ...</div><div>=C2=A0=C2= =A0=C2=A0 return result</div><div>=C2=A0</div><div>using macros (<a href=3D= "https://github.com/lihaoyi/macropy" target=3D"_blank">https://github.com/l= ihaoyi/macropy</a>) to perform this conversion at import time.</div> <div>=C2=A0</div><div>I have no idea if this is possible or not; could anyo= ne here give me any pointers or advice how to do this/why it is impossible?= </div><div>=C2=A0</div><div>Thanks!</div><div>-Haoyi</div></div></div><br>_= ______________________________________________<br> pypy-dev mailing list<br> <a href=3D"mailto:pypy-dev@python.org">pypy-dev@python.org</a><br> <a href=3D"http://mail.python.org/mailman/listinfo/pypy-dev" target=3D"_bla= nk">http://mail.python.org/mailman/listinfo/pypy-dev</a><br> <br></blockquote></div><br></div> --001a11c3715035453704dbec5495--

Hi, On Sun, May 5, 2013 at 11:12 AM, Maciej Fijalkowski <fijall@gmail.com> wrote:
Doesn't PyPy have a "compile to binary" option? I thought it did, but I may be mistaken.
It does not.
It does, in a way, but it's not an option available for the user on a single function at a time. The confusion comes from the RPython translator toolchain. This is how we produce PyPy, by translating into a binary the *whole* complete source code of PyPy (which is written in RPython, not in Python). There is no support to compile a single RPython function at a time --- or rather, there is, for our own testing purposes, but there is no reasonable way to integrate the result with the rest of your running Python code. As others have pointed out, you should not have to worry about it anyway because we have a JIT for full Python code. A bientôt, Armin.
participants (3)
-
Armin Rigo
-
Haoyi Li
-
Maciej Fijalkowski