[pypy-dev] Details on project idea: Explicit typing in RPython

Ryan Gonzalez rymg19 at gmail.com
Wed Mar 29 10:28:02 EDT 2017


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 at gmail.com> wrote:

> 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:
> > 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/
> >
> >
> > _______________________________________________
> > pypy-dev mailing list
> > pypy-dev at python.org
> > https://mail.python.org/mailman/listinfo/pypy-dev
> >
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> https://mail.python.org/mailman/listinfo/pypy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20170329/66583047/attachment.html>


More information about the pypy-dev mailing list