Skip to main content
QUICK REVIEW

[Paper 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 Science0 citations
TL;DR

Proposes a lightweight, amortized approach to select a subset of type annotations inferred for gradual typing to improve performance with shorter compilation time. Demonstrates gains on 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.

Motivation & Objective

  • Motivate the performance bottleneck in gradually typed languages where more type annotations can degrade performance.
  • Develop a lightweight method to select a subset of inferred type annotations to improve execution time.
  • Ensure the method maintains a practical compilation time while delivering performance benefits.
  • Demonstrate applicability on a Python subset using an external type inference engine.

Proposed method

  • Select type annotations along data flows to avoid expensive runtime casts across untyped/typed boundaries.
  • Use an amortized, lightweight selection process rather than full compilation-time strategies.
  • Leverage type inference to derive candidate annotations and choose a subset that optimizes execution performance.
  • Implement the approach in a Reticulated Python framework with an external inference engine.

Experimental results

Research questions

  • RQ1Can a subset of type annotations inferred by an external type inference engine improve execution performance in gradually typed programs?
  • RQ2Does the proposed amortized selection approach maintain shorter and more stable compilation times compared to full annotation strategies?
  • RQ3How does the method compare to naive strategies that use all inferred annotations in terms of runtime speed and compilation time?
  • RQ4Is the technique practically applicable to real-world gradually typed languages, demonstrated on Reticulated Python?

Key findings

  • The proposed selection technique yields better execution times than naive use of all inferred type annotations.
  • Compared to existing approaches, it achieves comparable execution speed while offering more stable compilation time.
  • Experiments in Reticulated Python show practical applicability for mitigating performance bottlenecks in gradually typed programs.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.