Gradual typing enables programmers to combine static and dynamic typing in the same language. However, ensuring sound interaction between the static and dynamic parts can incur runtime cost. In this paper, we analyze the performance of the transient design for gradual typing in Reticulated Python, a gradually typed variant of Python. This approach inserts lightweight checks throughout a program rather than installing proxies on higher order values. We show that, when using CPython as a host, performance decreases as programs evolve from dynamic to static types, up to a 6× slowdown compared to equivalent Python programs. To reduce this overhead, we design a static analysis and optimization that removes redundant runtime checks, employing a type inference algorithm that solves traditional subtyping constraints and also a new kind of check constraint. We evaluate the resulting performance and find that for many programs, the efficiency of partially typed programs is close to their untyped counterparts, removing most of the cost of transient checks. Finally, we measure the efficiency of Reticulated Python programs when running on PyPy, a tracing JIT. We find that combining PyPy with our type inference algorithm results in an average overhead of less than 1%.
CITATION STYLE
Vitousek, M. M., Siek, J. G., & Chaudhuri, A. (2019). Optimizing and evaluating transient gradual typing. In DLS 2019 - Proceedings of the 15th ACM SIGPLAN International Symposium on Dynamic Languages, co-located with SPLASH 2019 (pp. 28–41). Association for Computing Machinery, Inc. https://doi.org/10.1145/3359619.3359742
Mendeley helps you to discover research relevant for your work.