Skip to main content
QUICK REVIEW

[论文解读] Efficient Selection of Type Annotations for Performance Improvement in Gradual Typing

Senxi Li, Feng Dai|arXiv (Cornell University)|Mar 5, 2026
Software Engineering ResearchComputer Science被引用 0
一句话总结

提出了一种轻量化、摊销式的方法,从渐进类型化中推断的类型注解子集来提升性能,缩短编译时间。并在 Reticulated Python 上展示了收益。

ABSTRACT

Gradual typing has gained popularity as a design choice for integrating static and dynamic typing within a single language. Several practical languages have adopted gradual typing to offer programmers the flexibility to annotate their programs as needed. Meanwhile there is a key challenge of unexpected performance degradation in partially typed programs. The execution speed may significantly decrease when simply adding more type annotations. Prior studies have investigated strategies of selectively adding type annotations for better performance. However, they are restricted in substantial compilation time, which impedes the practical usage. This paper presents a new technique to select a subset of type annotations derived by type inference for improving the execution performance of gradually typed programs. The advantage of the proposal is shorter compilation time by employing a lightweight, amortized approach. It selects type annotations along the data flows, which is expected to avoid expensive runtime casts caused by a value repeatedly crossing the boundaries between untyped and typed code. We demonstrate the applicability of our proposal, and conduct experiments to validate its effectiveness of improving the execution time on Reticulated Python. Our implementation supports a Python subset to select type annotations derived by an implemented, external type inference engine. Experiment results show that our proposal outperforms a naive strategy of using all type annotations derived by type inference among the benchmark programs. In comparison with an existing approach, the proposal achieves comparable execution speed and shows advantage of maintaining a more stable compilation time of deriving and selecting type annotations. Our results empirically indicate that the proposed technique is practical within Reticulated Python for mitigating the performance bottleneck of gradually typed programs.

研究动机与目标

  • 在渐进类型语言中动机性能瓶颈:更多类型注解可能降低性能。
  • 开发一种轻量方法,选择推断的类型注解子集以改善执行时间。
  • 确保该方法在提供性能收益的同时保持可行的编译时间。
  • 在使用外部类型推断引擎的 Python 子集上展示适用性。

提出的方法

  • 沿数据流选择类型注解,以避免跨未类型/已类型边界的昂贵运行时强制转换。
  • 采用摊销式、轻量级的选择过程,而非全编译时策略。
  • 利用类型推断推导候选注解并选择子集以优化执行性能。
  • 在带外部推断引擎的 Reticulated Python 框架中实现该方法。

实验结果

研究问题

  • RQ1由外部类型推断引擎推断的类型注解子集是否能在渐进类型化程序中提升执行性能?
  • RQ2与完整注解策略相比,所提摊销选择方法是否保持更短且更稳定的编译时间?
  • RQ3与使用所有推断注解的天真策略相比,该方法在运行时速度和编译时间方面有何差异?
  • RQ4该技术是否可在现实世界的渐进类型语言中实际应用,并在 Reticulated Python 上得到证明?

主要发现

  • 所提出的选择技术在执行时间上优于天真使用所有推断类型注解的做法。
  • 与现有方法相比,在实现相近的执行速度的同时提供更稳定的编译时间。
  • 在 Reticulated Python 的实验表明,该方法对缓解渐进类型化程序的性能瓶颈具有实际可行性。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。