Provided in the present application are a method and apparatus for
type inference of a
programming language. The method comprises: in the process of developing program codes, acquiring a node to be inferred in an
abstract syntax tree, wherein said node indicates a field to be inferred in the program codes, said field comprising one of the following fields: a variable, a class, a function, or a parameter; acquiring a constraint related to said node, wherein the constraint is used for indicating a relationship involved in said node in the
abstract syntax tree; and on the basis of the constraint, determining the type of said node, wherein the type of said node is 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 meta type, a null
value type, or a callable type. The solution of the present application is conducive to reducing the memory usage of
type inference.