The application provides a
type inference method and device of a
programming language, the method comprising: in the development process of
program code, obtaining a node to be inferred in an
abstract syntax tree, the node to be inferred indicating a field to be inferred in the
program code, the field to be inferred comprising one of the following: a variable, a class, a function or a parameter; obtaining a constraint related to the node to be inferred, the constraint being used to indicate a relationship involved by the node to be inferred in the
abstract syntax tree; determining a type of the node to be inferred according to the constraint, the type of the node to be inferred being one of the following: a numeric type, a sequence type, a mapping type, a set type, an
iterator type, a
context manager type, a module type, a metatype, a null type or a callable type. The scheme of the application is beneficial to reducing the memory occupation of
type inference.