Translating safely (without executing)

Hello all, Is it possible to use PyPy's translation tool without having it execute the program? I think this would be important for programs with infinite loops, or ones which could do potentially dangerous things ie. when trying to translate a program to control a GPU fan, the fan was commanded off during a high work load. Thank you, Kirk

Hi Kirk, could you please provide more context? the translator does not execute the actual rpython program as code, just the surrounding imports (using python to metaprogramm the rpython) so its likely that the cpu fan off thing is a missunderstanding best, Ronny On 01/28/2013 11:37 PM, Kirk Liberty wrote:
Hello all,
Is it possible to use PyPy's translation tool without having it execute the program? I think this would be important for programs with infinite loops, or ones which could do potentially dangerous things ie. when trying to translate a program to control a GPU fan, the fan was commanded off during a high work load.
Thank you, Kirk _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev

ronny, Well the fan control command turned out not to be in rpython, so it failed to translate, but it still stopped the fan first. Here's an example of a program that would not translate because it just enters an infinite loop. from time import sleep def main(argv): while True: print "looping" sleep(1) return 0 def target(driver,args): return main,None main(1) command to translate > python ~/pypy/translator/goal/translate.py --batch --output loop loop.py Regards, Kirk On Mon, Jan 28, 2013 at 6:35 PM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
could you please provide more context?
the translator does not execute the actual rpython program as code, just the surrounding imports (using python to metaprogramm the rpython)
so its likely that the cpu fan off thing is a missunderstanding
best, Ronny
On 01/28/2013 11:37 PM, Kirk Liberty wrote:
Hello all,
Is it possible to use PyPy's translation tool without having it execute the program? I think this would be important for programs with infinite loops, or ones which could do potentially dangerous things ie. when trying to translate a program to control a GPU fan, the fan was commanded off during a high work load.
Thank you, Kirk _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev

Hi Kirk, you need to check for __name__ == '__main__' before the last line rpython does load code by importing and the last line will always run the program, guard it with a condition, and it will work fine best, Ronny On 01/29/2013 12:50 AM, Kirk Liberty wrote:
ronny,
Well the fan control command turned out not to be in rpython, so it failed to translate, but it still stopped the fan first. Here's an example of a program that would not translate because it just enters an infinite loop.
from time import sleep def main(argv): while True: print "looping" sleep(1) return 0 def target(driver,args): return main,None main(1)
command to translate> python ~/pypy/translator/goal/translate.py --batch --output loop loop.py
Regards, Kirk
On Mon, Jan 28, 2013 at 6:35 PM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
could you please provide more context?
the translator does not execute the actual rpython program as code, just the surrounding imports (using python to metaprogramm the rpython)
so its likely that the cpu fan off thing is a missunderstanding
best, Ronny
On 01/28/2013 11:37 PM, Kirk Liberty wrote:
Hello all,
Is it possible to use PyPy's translation tool without having it execute the program? I think this would be important for programs with infinite loops, or ones which could do potentially dangerous things ie. when trying to translate a program to control a GPU fan, the fan was commanded off during a high work load.
Thank you, Kirk _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev

On Tue, Jan 29, 2013 at 1:55 AM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
you need to check for __name__ == '__main__' before the last line
rpython does load code by importing and the last line will always run the program, guard it with a condition, and it will work fine
best, Ronny
On 01/29/2013 12:50 AM, Kirk Liberty wrote:
ronny,
Well the fan control command turned out not to be in rpython, so it failed to translate, but it still stopped the fan first. Here's an example of a program that would not translate because it just enters an infinite loop.
from time import sleep def main(argv): while True: print "looping" sleep(1) return 0 def target(driver,args): return main,None main(1)
command to translate> python ~/pypy/translator/goal/translate.py --batch --output loop loop.py
Regards, Kirk
On Mon, Jan 28, 2013 at 6:35 PM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
could you please provide more context?
the translator does not execute the actual rpython program as code, just the surrounding imports (using python to metaprogramm the rpython)
so its likely that the cpu fan off thing is a missunderstanding
best, Ronny
On 01/28/2013 11:37 PM, Kirk Liberty wrote:
Hello all,
Is it possible to use PyPy's translation tool without having it execute the program? I think this would be important for programs with infinite loops, or ones which could do potentially dangerous things ie. when trying to translate a program to control a GPU fan, the fan was commanded off during a high work load.
Thank you, Kirk _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev
Hi Kirk. Python is a meta-programming language for RPython, so no absolutely impossible. That said, why would you want to translate such programs?

Maciej, I could say I'm being stingy about CPU cycles since the program will be running continuously, but mostly "just because I can", or in this case can't. I think translation is pretty cool, and I've been trying to see what different things I can apply it to. What do you mean by "Python is a meta-programming language for RPython"? Regards, Kirk On Tue, Jan 29, 2013 at 2:49 AM, Maciej Fijalkowski <fijall@gmail.com> wrote:
On Tue, Jan 29, 2013 at 1:55 AM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
you need to check for __name__ == '__main__' before the last line
rpython does load code by importing and the last line will always run the program, guard it with a condition, and it will work fine
best, Ronny
On 01/29/2013 12:50 AM, Kirk Liberty wrote:
ronny,
Well the fan control command turned out not to be in rpython, so it failed to translate, but it still stopped the fan first. Here's an example of a program that would not translate because it just enters an infinite loop.
from time import sleep def main(argv): while True: print "looping" sleep(1) return 0 def target(driver,args): return main,None main(1)
command to translate> python ~/pypy/translator/goal/translate.py --batch --output loop loop.py
Regards, Kirk
On Mon, Jan 28, 2013 at 6:35 PM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
could you please provide more context?
the translator does not execute the actual rpython program as code, just the surrounding imports (using python to metaprogramm the rpython)
so its likely that the cpu fan off thing is a missunderstanding
best, Ronny
On 01/28/2013 11:37 PM, Kirk Liberty wrote:
Hello all,
Is it possible to use PyPy's translation tool without having it execute the program? I think this would be important for programs with infinite loops, or ones which could do potentially dangerous things ie. when trying to translate a program to control a GPU fan, the fan was commanded off during a high work load.
Thank you, Kirk _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev
Hi Kirk.
Python is a meta-programming language for RPython, so no absolutely impossible.
That said, why would you want to translate such programs?

On Tue, Jan 29, 2013 at 11:07 AM, Kirk Liberty <kirk.liberty@gmail.com> wrote:
Maciej,
I could say I'm being stingy about CPU cycles since the program will be running continuously, but mostly "just because I can", or in this case can't. I think translation is pretty cool, and I've been trying to see what different things I can apply it to.
I would seriously suggest pypy JIT here. It can sometimes even produce better results.
What do you mean by "Python is a meta-programming language for RPython"?
you can run some python before compiling RPython. we use all the tricks to say exec a bunch of methods.
Regards, Kirk
On Tue, Jan 29, 2013 at 2:49 AM, Maciej Fijalkowski <fijall@gmail.com> wrote:
On Tue, Jan 29, 2013 at 1:55 AM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
you need to check for __name__ == '__main__' before the last line
rpython does load code by importing and the last line will always run the program, guard it with a condition, and it will work fine
best, Ronny
On 01/29/2013 12:50 AM, Kirk Liberty wrote:
ronny,
Well the fan control command turned out not to be in rpython, so it failed to translate, but it still stopped the fan first. Here's an example of a program that would not translate because it just enters an infinite loop.
from time import sleep def main(argv): while True: print "looping" sleep(1) return 0 def target(driver,args): return main,None main(1)
command to translate> python ~/pypy/translator/goal/translate.py --batch --output loop loop.py
Regards, Kirk
On Mon, Jan 28, 2013 at 6:35 PM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
could you please provide more context?
the translator does not execute the actual rpython program as code, just the surrounding imports (using python to metaprogramm the rpython)
so its likely that the cpu fan off thing is a missunderstanding
best, Ronny
On 01/28/2013 11:37 PM, Kirk Liberty wrote:
Hello all,
Is it possible to use PyPy's translation tool without having it execute the program? I think this would be important for programs with infinite loops, or ones which could do potentially dangerous things ie. when trying to translate a program to control a GPU fan, the fan was commanded off during a high work load.
Thank you, Kirk _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev
Hi Kirk.
Python is a meta-programming language for RPython, so no absolutely impossible.
That said, why would you want to translate such programs?

2013/1/29 Kirk Liberty <kirk.liberty@gmail.com>
Maciej,
I could say I'm being stingy about CPU cycles since the program will be running continuously, but mostly "just because I can", or in this case can't. I think translation is pretty cool, and I've been trying to see what different things I can apply it to.
What do you mean by "Python is a meta-programming language for RPython"?
Please read: https://pypy.readthedocs.org/en/latest/you-want-to-help.html?highlight=meta#... -- Amaury Forgeot d'Arc

Ronny, I hadn't really thought of it as a program being imported, rather than just read as a text file. I'll add the check in my programs, thank you. Regards, Kirk On Mon, Jan 28, 2013 at 6:55 PM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
you need to check for __name__ == '__main__' before the last line
rpython does load code by importing and the last line will always run the program, guard it with a condition, and it will work fine
best, Ronny
On 01/29/2013 12:50 AM, Kirk Liberty wrote:
ronny,
Well the fan control command turned out not to be in rpython, so it failed to translate, but it still stopped the fan first. Here's an example of a program that would not translate because it just enters an infinite loop.
from time import sleep def main(argv): while True: print "looping" sleep(1) return 0 def target(driver,args): return main,None main(1)
command to translate> python ~/pypy/translator/goal/translate.py --batch --output loop loop.py
Regards, Kirk
On Mon, Jan 28, 2013 at 6:35 PM, Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de> wrote:
Hi Kirk,
could you please provide more context?
the translator does not execute the actual rpython program as code, just the surrounding imports (using python to metaprogramm the rpython)
so its likely that the cpu fan off thing is a missunderstanding
best, Ronny
On 01/28/2013 11:37 PM, Kirk Liberty wrote:
Hello all,
Is it possible to use PyPy's translation tool without having it execute the program? I think this would be important for programs with infinite loops, or ones which could do potentially dangerous things ie. when trying to translate a program to control a GPU fan, the fan was commanded off during a high work load.
Thank you, Kirk _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev

Hi Kirk, On Mon, Jan 28, 2013 at 11:37 PM, Kirk Liberty <kirk.liberty@gmail.com> wrote:
Is it possible to use PyPy's translation tool without having it execute the program?
As you got it, the answer to that is no. I updated https://pypy.readthedocs.org/en/latest/faq.html#do-i-have-to-rewrite-my-prog... . A bientôt, Armin.

Armin, I read your addition to the FAQ, I think I understand now the purpose of RPython and why I should just use the PyPy JIT for my programs. Kirk On Jan 30, 2013 3:26 AM, "Armin Rigo" <arigo@tunes.org> wrote:
Hi Kirk,
On Mon, Jan 28, 2013 at 11:37 PM, Kirk Liberty <kirk.liberty@gmail.com> wrote:
Is it possible to use PyPy's translation tool without having it execute the program?
As you got it, the answer to that is no. I updated
https://pypy.readthedocs.org/en/latest/faq.html#do-i-have-to-rewrite-my-prog... .
A bientôt,
Armin.
participants (5)
-
Amaury Forgeot d'Arc
-
Armin Rigo
-
Kirk Liberty
-
Maciej Fijalkowski
-
Ronny Pfannschmidt