[pypy-dev] Translating safely (without executing)

Maciej Fijalkowski fijall at gmail.com
Tue Jan 29 10:13:20 CET 2013


On Tue, Jan 29, 2013 at 11:07 AM, Kirk Liberty <kirk.liberty at 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 at gmail.com> wrote:
>> On Tue, Jan 29, 2013 at 1:55 AM, Ronny Pfannschmidt
>> <Ronny.Pfannschmidt at 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 at 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 at python.org
>>>>>> http://mail.python.org/mailman/listinfo/pypy-dev
>>>>>
>>>>>
>>>>>
>>>
>>> _______________________________________________
>>> pypy-dev mailing list
>>> pypy-dev at 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?


More information about the pypy-dev mailing list