Python probabilistic type inference with natural language support
Zhaogui Xu, Xiangyu Zhang, Lin Chen et al. · ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE) · 2016
We propose a novel type inference technique for Python programs. Type inference is difficult for Python programs due to their heavy dependence on external APIs and the dynamic language features. We observe that Python source code often contains a lot of type hints such as attribute accesses and variable names. However, such type hints are not reliable. We hence propose to use probabilistic inference to allow the beliefs of individual type hints to be propagated, aggregated, and eventually converge on probabilities of variable types. Our results show that our technique substantially outperforms a state-of-the-art Python type inference engine based on abstract interpretation.
Cited by 95 works. doi:10.1145/2950290.2950343 Open-access PDF
Authors
References
- Understanding belief propagation and its generalizations
- Bayesian face recognition
- Scaling Java Points-to Analysis Using Spark
- Type Analysis for JavaScript
- Towards Type Inference for JavaScript
- Predicting Program Properties from "Big Code"
- Towards a Type System for Analyzing JavaScript Programs
- PyPy's approach to virtual machine construction
- Jalangi: a selective record-replay and dynamic analysis framework for JavaScript
- From uncertainty to belief: inferring the specification within