Precise and fast static type analysis for dynamically typed language is very difficult. This is mainly because the lack of static type information makes it difficult to approximate all possible values of a variable. Actually, the existing static type analysis methods are imprecise or slow. In this paper, we propose a novel method to improve the precision of static type analysis for Python code, where a backward analysis is used to obtain the path-sensitivity. By doing so, our method aims to obtain more precise static type information, which contributes to the overall improvement of static analysis. To show the effectiveness of our method, we conducted a preliminary experiment to compare our method implementation and the existing analysis tool with respect to precision and time efficiency. The result shows our method provides more precise type analysis with fewer false positives than the existing static type analysis tool. Also it shows our proposed method increases the analysis time, but it is still within the range of practical use.
翻译:对于动态类型语言而言,实现精确且快速的静态类型分析极为困难。这主要是因为缺乏静态类型信息,导致难以准确逼近变量的所有可能取值。实际上,现有的静态类型分析方法要么精度不足,要么效率低下。本文提出了一种新颖方法,通过引入逆向分析实现路径敏感性,从而提升Python代码静态类型分析的精度。通过这种方式,我们的方法旨在获取更精确的静态类型信息,进而全面改善静态分析的整体效果。为验证方法的有效性,我们开展了初步实验,将方法实现与现有分析工具在精度和时间效率方面进行了对比。结果表明,与现有静态类型分析工具相比,我们的方法能以更少的误报提供更精确的类型分析。同时,该方法虽然增加了分析时间,但仍处于实际可用的范围内。