Open-access article

Type inference for Python programming language

Type inference for Python programming language

Download full textFree with an account; signing up with Google takes seconds

Abstract

The article presents type inference for programs written in Python programming language. At first, type inference algorithms for parametric polymorphism that were described in the scientific literature are reviewed. The algorithms evolved from “basic” algorithm (also known as Palsberg — Schwartzbach algorithm) to Cartesian product algorithm (CPA). It was shown that CPA is both precise and efficient, however it has to be modified to be used on Python code. Afterwards, we present a new algorithm (a modification of CPA) for Python. It is shown how type inference module using the new algorithm analyses various Python language structures: constants (literals), basic Python collections, variable names, assignments, function and class definitions, attribute and index expressions. It is also shown how the algorithm deals with external (non-Python) functions using special annotations that specify output types depending on input types of the function. Afterwards, the results of work on the prototype (module that implements described type inference algorithm) are presented. The paper is concluded by an overview of possible future work directions such as generating a defect trace, i.e. description that specifies how expression got its incorrect types.

Similar items

  • Type Inference for Programming Languages: A Constraint Logic Programming Approach

    Scholarly record2004Sandra Alves, Mário Florido

    In this paper we present an application of Constraint Logic Programming to the design and implementation of type inference algorithms for programming languages. We present implementations in Prolog and Constraint Handling Rules (CHR) of several algorithms which belong to the stat

  • Usage of the Python Programming Language in the CMS Experiment

    Scholarly record2009R. Wilkinson, B. Hegner

    Being a highly dynamic language and allowing reliable programming with quick turnarounds, Python is a widely used programming language in CMS. Most of the tools used in workflow management and the GRID interface tools are written in this language. Also most of the tools used in t

  • Usage of the Python programming language in the CMS experiment

    Open-access article2010Journal of Physics: Conference SeriesRWilkinson, BHegner, C DJones

    Being a highly dynamic language and allowing reliable programming with quick turnarounds, Python is a widely used programming language in CMS. Most of the tools used in workflow management and the GRID interface tools are written in this language. Also most of the tools used in t

  • The Python programming language as an alternative tool for solving tasks of the Unified State Exam in informatics

    Open-access article2023??????????? ? ?????['V. K. Markelov', 'O. A. Zavyalova', '']

    Programming is the basis of the content line "Algorithms and programming", which is studied throughout the entire school course of informatics, therefore programming tasks are one of the thematic blocks of the Unified State Exam (USE) in informatics. In particular, one of the edu

  • A Tested Semantics for the Python Programming Language

    Scholarly record2013Joe Gibbs Politz, Alejandro Martinez, Matthew Milano, Daniel Patterson

    We present a small-step operational semantics for the Python programming language. We present both a core language for Python, suitable for tools and proofs, and a translation process for converting Python source to this core. We have tested the composition of translation and eva

  • On the performance of the Python programming language for serial and parallel scientific computations

    Scholarly record2005Scientific ProgrammingXing Cai, Hans Petter Langtangen, Halvard Moe

    This article addresses the performance of scientific applications that use the Python programming language. First, we investigate several techniques for improving the computational efficiency of serial Python codes. Then, we discuss the basic programming techniques in Python for