Details on project idea: Explicit typing in RPython

Hello, I am interested in working on the above project. I need to understand what it is about so that I can make a plan for it. I would love to work on it for GSoC if accepted. In summary..I want to know the goal and the most important stack involved working on it. I am proficient in python. If the above project idea is not so much in that direction you can advise a better idea among the ones listed here http://pypy.readthedocs.io/en/latest/project-ideas.html. Kind regards, -- Joannah Nanjekye +256776468213 F : Nanjekye Captain Joannah S : joannah.nanjekye T : @captainjoannah SO : joannah *"You think you know when you learn, are more sure when you can write, even more when you can teach, but certain when you can program." Alan J. Perlis*

Hello Joannah, Ronan might know more about this topic. But here is a short explanation: A solid start is to read the following documentation: http://rpython.readthedocs.io/en/latest/translation.html It explains how Python source code is analyzed, transformed and compiled. As you know, there are no type annotations as a "static" language provides (like C++, C, Java, ...). def foo(a,b): return a * b The two parameters a and b can carry any type (even the ones that are not able to execute binary add). One step of the transformation described in the link above "annotates" the types and deduces other properties. If you have a call site: foo("a", 2) It will deduce that foo's parameter a is an instance of "SomeString" and b is an instance of "SomeInteger". So it will assume that when foo is called every call site must provide SomeString for a and SomeInteger for b (or a subtype, but I'm not aware of the full details). If at another place foo(1,2) is called (which is valid python), rpython must complain, because it cannot be statically compiled. What we would like is a way to explicitly annotate the types (be aware that this is just an example, it is up to you how you solve it): @explicit_types(a=SomeInteger, b=SomeInteger) def foo(a,b): return a * b This would mean that rpython would complain as soon as it sees foo("a", 2). Preferably I think it would be good to have a mini language to describe such function properties, or variable properties. Cheers, Richard On 03/28/2017 10:14 AM, joannah nanjekye wrote:

RPython already has this: https://bitbucket.org/pypy/pypy/src/tip/rpython/rlib/signature.py -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On Mar 29, 2017 7:01 AM, "Richard Plangger" <planrichi@gmail.com> wrote:

Le 29/03/17 à 15:28, Ryan Gonzalez a écrit :
RPython already has this:
https://bitbucket.org/pypy/pypy/src/tip/rpython/rlib/signature.py
Indeed, @signature is one of 2 prior attempts at doing this in rpython[*]. However its syntax is cumbersome and it's rather limited in the types it can express - you can only use what's in rpython.rlib.types and these functions cannot be combined arbitrarily to build more complex types. [*] The other one is @enforceargs: https://bitbucket.org/pypy/pypy/src/tip/rpython/rlib/objectmodel.py

Thank you I think this is clearer to me now. On Wed, Mar 29, 2017 at 6:34 PM, Ronan Lamy <ronan.lamy@gmail.com> wrote:
-- Joannah Nanjekye +256776468213 F : Nanjekye Captain Joannah S : joannah.nanjekye T : @captainjoannah SO : joannah *"You think you know when you learn, are more sure when you can write, even more when you can teach, but certain when you can program." Alan J. Perlis*

Hello It is kinda last minute but if some one has a minute, kindly give me some feedback for my GSoC proposal here https://docs.google.com/document/d/1tidHKzTWOLDILPsUag8Vc0aS-lsIzwHDYvuGQ-hR... before I submit. Kind regards, On Fri, Mar 31, 2017 at 1:44 PM, joannah nanjekye <nanjekyejoannah@gmail.com
wrote:
-- Joannah Nanjekye +256776468213 F : Nanjekye Captain Joannah S : joannah.nanjekye T : @captainjoannah SO : joannah *"You think you know when you learn, are more sure when you can write, even more when you can teach, but certain when you can program." Alan J. Perlis*

Hi, I would suggest to change the deliverables. We already have a way to specify the type for function signatures (mentioned in this email thread). It should at least mention that you extend those. It would be also very useful if you kind of gave an example how the mini language (e.g. specified in the doc string) would look like. Could we maybe use mypy for that? In the end that is an open question .. (to be solved by you :) If I'm correct you got 1h left to change the document!! Cheers, Richard On 04/02/2017 04:50 AM, joannah nanjekye wrote:

Thanks for taking time to give me feedback. I have tried to make the necessary changes swiftly(last minute). I hope I dint misrepresent alot. Kind regards, joannah On Mon, Apr 3, 2017 at 6:01 PM, Richard Plangger <planrichi@gmail.com> wrote:
-- Joannah Nanjekye +256776468213 F : Nanjekye Captain Joannah S : joannah.nanjekye T : @captainjoannah SO : joannah *"You think you know when you learn, are more sure when you can write, even more when you can teach, but certain when you can program." Alan J. Perlis*

Hello Joannah, Ronan might know more about this topic. But here is a short explanation: A solid start is to read the following documentation: http://rpython.readthedocs.io/en/latest/translation.html It explains how Python source code is analyzed, transformed and compiled. As you know, there are no type annotations as a "static" language provides (like C++, C, Java, ...). def foo(a,b): return a * b The two parameters a and b can carry any type (even the ones that are not able to execute binary add). One step of the transformation described in the link above "annotates" the types and deduces other properties. If you have a call site: foo("a", 2) It will deduce that foo's parameter a is an instance of "SomeString" and b is an instance of "SomeInteger". So it will assume that when foo is called every call site must provide SomeString for a and SomeInteger for b (or a subtype, but I'm not aware of the full details). If at another place foo(1,2) is called (which is valid python), rpython must complain, because it cannot be statically compiled. What we would like is a way to explicitly annotate the types (be aware that this is just an example, it is up to you how you solve it): @explicit_types(a=SomeInteger, b=SomeInteger) def foo(a,b): return a * b This would mean that rpython would complain as soon as it sees foo("a", 2). Preferably I think it would be good to have a mini language to describe such function properties, or variable properties. Cheers, Richard On 03/28/2017 10:14 AM, joannah nanjekye wrote:

RPython already has this: https://bitbucket.org/pypy/pypy/src/tip/rpython/rlib/signature.py -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On Mar 29, 2017 7:01 AM, "Richard Plangger" <planrichi@gmail.com> wrote:

Le 29/03/17 à 15:28, Ryan Gonzalez a écrit :
RPython already has this:
https://bitbucket.org/pypy/pypy/src/tip/rpython/rlib/signature.py
Indeed, @signature is one of 2 prior attempts at doing this in rpython[*]. However its syntax is cumbersome and it's rather limited in the types it can express - you can only use what's in rpython.rlib.types and these functions cannot be combined arbitrarily to build more complex types. [*] The other one is @enforceargs: https://bitbucket.org/pypy/pypy/src/tip/rpython/rlib/objectmodel.py

Thank you I think this is clearer to me now. On Wed, Mar 29, 2017 at 6:34 PM, Ronan Lamy <ronan.lamy@gmail.com> wrote:
-- Joannah Nanjekye +256776468213 F : Nanjekye Captain Joannah S : joannah.nanjekye T : @captainjoannah SO : joannah *"You think you know when you learn, are more sure when you can write, even more when you can teach, but certain when you can program." Alan J. Perlis*

Hello It is kinda last minute but if some one has a minute, kindly give me some feedback for my GSoC proposal here https://docs.google.com/document/d/1tidHKzTWOLDILPsUag8Vc0aS-lsIzwHDYvuGQ-hR... before I submit. Kind regards, On Fri, Mar 31, 2017 at 1:44 PM, joannah nanjekye <nanjekyejoannah@gmail.com
wrote:
-- Joannah Nanjekye +256776468213 F : Nanjekye Captain Joannah S : joannah.nanjekye T : @captainjoannah SO : joannah *"You think you know when you learn, are more sure when you can write, even more when you can teach, but certain when you can program." Alan J. Perlis*

Hi, I would suggest to change the deliverables. We already have a way to specify the type for function signatures (mentioned in this email thread). It should at least mention that you extend those. It would be also very useful if you kind of gave an example how the mini language (e.g. specified in the doc string) would look like. Could we maybe use mypy for that? In the end that is an open question .. (to be solved by you :) If I'm correct you got 1h left to change the document!! Cheers, Richard On 04/02/2017 04:50 AM, joannah nanjekye wrote:

Thanks for taking time to give me feedback. I have tried to make the necessary changes swiftly(last minute). I hope I dint misrepresent alot. Kind regards, joannah On Mon, Apr 3, 2017 at 6:01 PM, Richard Plangger <planrichi@gmail.com> wrote:
-- Joannah Nanjekye +256776468213 F : Nanjekye Captain Joannah S : joannah.nanjekye T : @captainjoannah SO : joannah *"You think you know when you learn, are more sure when you can write, even more when you can teach, but certain when you can program." Alan J. Perlis*
participants (4)
-
joannah nanjekye
-
Richard Plangger
-
Ronan Lamy
-
Ryan Gonzalez