Towards a type-based abstract semantics for Python

Python is a high-level programming language that is strongly, but dynamically typed. In this paper, we propose a type inference framework to compute specifications for Python functions in isolation. To achieve this, we aim to use an abstract-interpretation-based data flow analysis to infer variable types on a subset of Python programs that use built-in types, operators and functions. To evaluate the expressions found in every program point, specifications for the encountered operations and functions are required. We propose a method for extracting these specifications from the Typeshed project, which contains a set of annotations for built-in and popular third-party libraries. These specifications will be used then to extend the proposed type inference to large Python programs. • Static analysis is used to infer types of variables for a subset of Python programs. • The type inference is achieved by combining dataflow analysis, abstract interpretation, and a constraint solver. • Annotations can be translated to a more formal model, that can be used for variable type inference for larger programs.

Authors

Institutions

Publication Details

Journal
Journal of Logical and Algebraic Methods in Programming
Published
2024-12-10
DOI
https://doi.org/10.1016/j.jlamp.2024.101032
Citations
4
Primary Topic
Logic, programming, and type systems
Type
article
Field-Weighted Citation Impact
1.39
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Towards a type-based abstract semantics for Python

Andrei Nacu
4 citations
Journal of Logical and Algebraic Methods in Programming
Logic, programming, and type systems
1.39
article

Towards a type-based abstract semantics for Python

Andrei Nacu
article en
4 citations

Abstract

Python is a high-level programming language that is strongly, but dynamically typed. In this paper, we propose a type inference framework to compute specifications for Python functions in isolation. To achieve this, we aim to use an abstract-interpretation-based data flow analysis to infer variable types on a subset of Python programs that use built-in types, operators and functions. To evaluate the expressions found in every program point, specifications for the encountered operations and functions are required. We propose a method for extracting these specifications from the Typeshed project, which contains a set of annotations for built-in and popular third-party libraries. These specifications will be used then to extend the proposed type inference to large Python programs. • Static analysis is used to infer types of variables for a subset of Python programs. • The type inference is achieved by combining dataflow analysis, abstract interpretation, and a constraint solver. • Annotations can be translated to a more formal model, that can be used for variable type inference for larger programs.

Journal of Logical and Algebraic Methods in ProgrammingVol. 143
Alexandru Ioan Cuza University (RO)
Openalex Percentile: Top 15%
Logic, programming, and type systems
1.39
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.