From: Jan W. <xi...@mi...> - 2016-11-06 14:41:27
|
To Jython devs, I am a 3rd year PhD student at University of Warsaw and I wanted to do my Python static typing research by implementing it as a part of Jython. Before starting, I would like to hear your opinion on combining my research with Jython, and whether it would have a chance to be integrated into the main Jython branch after it is complete. Below I describe my plans. My research ----------- I want to statically type Python, which means constructing automatic type inference of most objects (incl. functions and classes) present in a Python program. The type system I am working on consists of: - primitives, - objects, i.e. dictionaries from strings known at compile time to types of values contained there, - functions, - constructs like "TypeA or TypeB", "FunctionTypeA and FunctionTypeB". In other words, before even running a program, I want to compute what properties each variable present in it has, and recursively what are properties of those properties, until I get to primitives or function bodies. The Python type inference algorithm I have in mind would take the Python AST, convert it to a simpler Lucretia language and make the type inference there. Lucretia is a language designed by Viviana Bono, Marcin Benke and Aleksy Schubert (my PhD supervisor) for the purpose of static typing of dynamic languages (pdf: https://arxiv.org/pdf/1206.5112.pdf). One of the features of my project is that I would like to support full Python language instead of subset of its features that are typeable (like mypy does: http://mypy-lang.org/). Since it is provably impossible to make type inference algorithm working for all Python programs, I want to use gradual typing and treat all variables that my algorithm was not able to process as "dynamic". As for similar research projects, I'd say Reticulated Python by Michael M. Vitousek, Andrew M. Kent, Jeremy G. Siek and Jim Baker is the closest one to what I would like to achieve (pdf: http://wphomes.soic.indiana.edu/jsiek/files/2014/03/retic-python.pdf). Reticulated Python also does not seem to restrict allowed language constructs, but it has slightly different type system and different policy on handling imports (kind of at runtime instead of statically). I noticed that Jim Baker is not only sub-author of Reticulated Python paper, but also a major commiter to Jython, so I am interested in hearing if some of the work from Reticulated Python is already integrated into Jython. Combining with Jython --------------------- The type inference in Lucretia and combining its results with Python is something new and I would like to implement it as a part of Jython. The current Jython implementation would help me with parsing, execution, and generally with lots of technical stuff. I was originally going to target only recent versions of Python 3, but I am open for changes, even to Python 2.7. If the general idea is welcome, I am also open to other major changes. I think that there could be two main applications of my research: - Improvement of IDEs - after exposing some Jython internals connected to my work, more precise type information could be made available to an IDE. As many IDEs run on JVM, the integration could also be smoother. - Producing faster, more optimized for JVM bytecode - although it is not the main goal of Jython, more speed is always better. I believe I could do that in situations where I could prove that no properties would be ever dynamically added to an object, existing ones would not change their type and I could resolve statically all called methods. Jan Wroblewski http://www.mimuw.edu.pl/~xi/ |