[Python-ideas] Possible enhancement to typing

Guido van Rossum guido at python.org
Mon Nov 6 20:58:02 EST 2017

On Mon, Nov 6, 2017 at 2:34 AM, Stéfane Fermigier <sf at fermigier.com> wrote:

> 4) 10 years ago, when I was working on the EDOS project (
> http://cordis.europa.eu/pub/ist/docs/directorate_d/st-ds/
> edos-project-story_en.pdf ), I ran a small experiment where I used, IIRC,
> the profile hook to intercept all function / method calls, and log
> information about arguments and return value types to a gigantic log file.
> Then the log file could be parsed and these information used to suggest
> type annotations. Except there were no type annotations at the time in
> Python.
> I know PyCharm can do a similar thing now: you run your program or your
> tests under the debugger, it logs runtime type information somewhere, and
> then can use it to suggest autocompletion or maybe type annotations.

I didn't know this. Do you know where there are docs for this feature?

> Now I believe something could be done along the lines:
> a) record runtime type information from test or regular runs
> b) massage these information and use them to annotate Python code with
> additional type information (up to the developer to then accept or not the
> proposed changes)

We have an early version of a tool that does this at Dropbox; I am planning
to open-source it by the end of this year. So far the experience is that
the annotations require a fair amount of manual cleanup though.


> Similar to "Measuring Polymorphism in Python Programs", by Beatrice
Akerblom and Tobias Wrigstad:
> https://people.dsv.su.se/~beatrice/python/dls15_large_images.pdf

Thanks for the link!

--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171106/f84ee6fe/attachment.html>

More information about the Python-ideas mailing list