Changelog¶
All notable changes to TyPy are recorded here. The format follows Keep a Changelog, and TyPy uses semantic versioning.
Unreleased¶
Added¶
- The documentation is published at https://typy-lang.org, built from
the sources of each release when the release is published. It is a site
with navigation, search, and light and dark modes, laid out in the
sections of Python's documentation: What's new, the tutorial, the
library and language references, setup and usage, extending and
embedding, and diagnostics, with the engineering documents and pages
about the site, its copyright and its licence.
make docsbuilds it intosite/with Zensical in strict mode, andmake checkruns it, so a broken link or anchor, or a page missing from the navigation, fails the quality gate (DOC-05, ADR-0050). - A What's new page for each release, starting with TyPy 0.5, and the changelog as a page of the site.
Changed¶
- The user documentation is laid out in sections, as Python's
documentation is, and its pages moved under
docs/.user/getting-started.mdistutorial/index.md.user/guide/index.mdisreference/index.md, the language reference, which holds the guide's pages on the language under their names.built-in-types.mdandexceptions.mdmoved tolibrary/, andlibrary.mdislibrary/functions-and-modules.md.command-line.mdisusing/command-line.md,c-interop.mdisextending/c-interop.md,diagnostics.mdisdiagnostics/index.md, anduser/troubleshooting.mdisdiagnostics/troubleshooting.md.docs/index.mdis the start page of the user documentation, and the list of engineering documents moved todocs/engineering.md(DOC-02).
Fixed¶
- The release archive carries
THIRD-PARTY-NOTICES.md, with the licence and copyright notice of the Python Software Foundation for the parts of the runtime derived from CPython's source (the list sort and parts ofmath) and the Unicode licence for its Unicode tables. Releases 0.1.0 to 0.5.0 shipped these parts without the notices. The runtime's package metadata gives its licence as(MIT OR Apache-2.0) AND PSF-2.0 AND Unicode-3.0. - The release archive's
licenses/directory holds the licences of the Rust crates and the LLVM thattypylinks and of Rust's standard library, which the archives of 0.1.0 to 0.5.0 lacked.
0.5.0 - 2026-11-17¶
Added¶
- An instance of a class of the program that never outlives the function
that makes it is made in the function's frame, with no allocator call:
one the function reads, assigns attributes of, calls methods on, or
passes to functions that do no more.
--emit=tyirends the line of each such instance within frame(MEM-03, ADR-0042). - The table
[allocator]intypy.tomlnames the C functions a program allocates with, in place ofmalloc,reallocandfree, and the library that defines them, such as mimalloc'smi_malloc,mi_reallocandmi_freefrommimalloc. A wrong table is E0107 (MEM-08, ADR-0043). typy build --lib staticand--lib sharedbuild a module as a C library,libNAME.aorlibNAME.so, with the C headerNAME.h. The functions__all__lists are exported under their own names, withint,floatandboolasint64_t,doubleandbool. The module runs when the library is loaded, and is named after its file. An exception that would leave an export ends the process: aSystemExitwith its status, any other with its report and an abort. E0429 names a module or an export a library cannot have;typy check --libreports it too (CLI-09, FFI-05, EXC-05, ADR-0044).- A library's files carry the release of its version, from the module's
__version__or elseversionintypy.toml, as Linux names libraries:libNAME.so.5.0with the sonamelibNAME.so.5and linkslibNAME.so.5andlibNAME.so, andlibNAME.5.0.awith a linklibNAME.a(CLI-13, ADR-0045). - A library build also writes
NAME_binding.py, a module that loads the library withctypesby its soname and defines a typed function for each export, and its stubNAME_binding.pyi, so a Python program imports the binding and calls the library (FFI-08, ADR-0046). ctypes: a library a module declares withctypes.CDLL("name")orctypes.cdll.LoadLibrary("name")is linked when the program is built, and a C function whoseargtypesandrestypeare assigned at module level is called directly, with every integer type fromc_int8toc_uint64,c_float,c_double,c_bool,c_char_pandc_void_pconverted asctypesconverts them, alsoctypes.ArgumentErrorfor aninttoo large for afloat. E0430 names a declaration TyPy cannot compile (FFI-01 to FFI-03, ADR-0047).ctypesobjects, pointers and arrays:c_int(5)and every scalar type ofctypesmake an object whosevaluea program reads and assigns and a C function writes throughbyref(x)or aPOINTER(T)parameter;pointer(x),POINTER(T)(),contentsand indexes read and write through a pointer, which a C function may also return;(T * n)(...)makes an array withlen, checked indexes, iteration andin; andsizeofgives a class's size, each as in CPython.argtypesandrestypetakePOINTER(T)and names bound to a type (FFI-03, ADR-0048).ctypes.Structuresubclasses with a literal_fields_list, laid out as C lays out a struct: fields read and assign as in CPython, a structure, array or pointer field reads as an object over its memory, structures nest, fill arrays and sit behind pointers, and a C function takes and returns a structure by value as the x86-64 System V calling convention passes it, in registers or in memory (FFI-03, ADR-0049).library-pathsand[libraries."NAME"]withlink = "static"or"dynamic"intypy.tomlsay where the linker looks for C libraries and how each is linked (FFI-04).- A benchmark report,
docs/testing/benchmark-report.md, which compares TyPy's programs with CPython 3.12 to 3.15, PyPy, mypyc, Cython, Nuitka, Codon, C, C++, Rust, Go, Java and JavaScript on twelve workloads: time, peak memory, startup, build time and size.make bench-peersinstalls the peers at pinned versions andmake bench-compareruns it. - Assignment expressions,
name := value, with CPython's scoping in comprehensions and its syntax errors; a test of(name := value) is not Nonenarrowsname(EXP-13). matchstatements with literal, value, capture, wildcard,as,|, sequence, mapping and class patterns and guards, with CPython's syntax errors for patterns. A class pattern reads__match_args__from the class body or a base, and a class pattern that CPython would answer withTypeErroris refused with E0401. A case narrows the subject as the test it stands for does, so aftercase None:an optional subject is no longerNone, andcase [x, *rest]narrows alist[int] | Noneto the list (CST-06).- The warning W0401 for a
matchwhose cases leave members of the subject's union, optional orbooltype unmatched, naming them. Amatchwhose cases cover every member is complete, so a function that returns from each case needs noreturnafter it (CST-07, ADR-0033). @dataclasswrites__match_args__, the names of the fields, and takesmatch_args=Falseto leave it out (CLS-05, CST-06).- The names
Optional,Union,List,Dict,Set,TupleandTypeoftypingin annotations, as the types they spell (LIB-17). IterableandIteratoroftypingandcollections.abc, andList,Dict,Set,Tuple,Type,Optional[...]andUnion[...]oftyping, as the class ofisinstanceand of a class pattern, with CPython's answers (TYP-17).- A loop, a comprehension,
list,sorted,sumand the other builtins that read an iterable go over a variable that holds a union of fixed tuples, such astuple[str] | tuple[str, int](TYP-14, ADR-0034). argsof an exception andcodeof aSystemExitare values of their own: stored, passed, indexed, unpacked and looped over. The type ofargscomes from every creation of the class and of the classes derived from it, in the program and in TyPy's own raises, such astuple[str, int] | tuple[str];codeisNone, the one argument, or the tuple. The five items of a Unicode error join only in a program that encodes, decodes or opens a file (EXC-15, ADR-0034).- A class may define the in-place methods, such as
__iadd__, whichx += ycalls, falling back to__add__; an augmented assignment that calls an operator method takes an item or an attribute of any expression as its target, evaluated once (CLS-20, CLS-32). - Assigning a class variable through a subclass that inherits it gives
the subclass a variable of its own, which it, its subclasses and their
instances read from then on, as CPython does; through a variable such
as
clsit is planned for 1.0 (CLS-25, CLS-31, ADR-0037). - A class method may be called through an instance, which passes the
instance's class as
cls, and through a subclass defined in another module than the class that defines it, which gets a copy of its own. Through an instance of a generic class it is planned for 1.0 (CLS-25, CLS-30, ADR-0037). - A static method may be called through any expression that gives an
instance, such as
make().helper(), which is evaluated first, as CPython does (CLS-25). super(Base, self)takes any class of the enclosing class's chain of bases, and finds the method of the nearest base ofBase, as CPython does; with another instance it is planned for 1.0 (CLS-26, CLS-29).- Dataclasses take
field(default_factory=f), called for each instance that is not given the field, hash as the tuple of their fields when frozen or givenunsafe_hash=True, and take the optionsinit,repr,unsafe_hashandslots, as CPython'sdataclassesdoes. Other options offieldand@dataclassare planned for 1.0 (CLS-15, CLS-16, CLS-17, CLS-28). math.fsum,dist,prodandsumprodtake items of a union of number types, such as alist[int | float], andprodaboolstart, with CPython's results.prodof items that are not numbers is planned for 1.0 (LIB-15, LIB-21).- A function may import a module that imports its own module at module
level, the usual way to break an import cycle, as CPython allows; the
function is checked once that module is. Inside
__init__it is planned for 1.0 (MOD-13, MOD-15). OSErrortakes arguments of any type, more than five of them, and two or more throughsuper().__init__or to a subclass with an__init__of its own, as CPython does:OSError("a", "b")is[Errno a] b.errno,strerror,filenameandfilename2take their types from every creation of the class, and an error about a file opened from a descriptor has the descriptor asfilename. A number as the third argument ofOSErrororBlockingIOErroris planned for 1.0 (EXC-16, EXC-18, ADR-0035).- A literal index into a variable that holds a union of fixed tuples
raises
IndexErrorwhen the tuple it holds is too short, as CPython does, in place of E0307; a position outside every member is still E0307 (DAT-08). sys.version_infoas a value of its own: stored, put in containers, imported withfrom sys import version_infoand printed as CPython writes it, and read as the tuple of its items by indexing, slicing, comparing,len, loops and unpacking (LIB-16).- Type aliases of another module, by name or through the module,
typestatements inside functions, classes and blocks, and bounds and constraints on an alias's type parameters, and an alias read as a value, atyping.TypeAliasTypewith__name__and__module__(SMT-12). - One value assigned to several targets, as in
a = items[0] = value, or unpacked into targets, is held by each target as its own type, a union or an optional among them (TYP-16). - A
\uor\Uescape of a surrogate in astrliteral or an f-string gives that code point, as CPython keeps it (LEX-10). NotImplemented. An operator or comparison method that returns it gives way to the other operand's reflected method, and an in-place method to the binary methods; when every method gives way,==and!=compare identities and other operators raise CPython'sTypeError. Lists, sets and dicts compare through an__eq__that gives way, and so do ordering methods (CLS-22); a method that also returnsNoneis planned for 1.0 (CLS-33).return NotImplementedelsewhere is E0405 (CLS-21, ADR-0038).- Comparison, hash and truth methods that may raise, or that print, inside
lists, sets, dicts,
sorted,min,max,anyandall: the first exception leaves the operation, no later method runs, and a set or a dict keeps its items. An ordering method that returnsNotImplementedworks in a sort too (CLS-21, CLS-22, ADR-0039). - A chain of comparisons of instances, such as
low < value < high, calls each comparison's method and evaluates each operand once (CLS-22). - An operator whose method and reflected method return different types; the operator's type joins them when the reflected method may run (CLS-22).
inon an instance whose class has__iter__and no__contains__goes over its items until one is the value or equal to it, as CPython does; over a class with__getitem__alone it is planned for 1.0 (CLS-23, CST-11).sliceobjects:x[a:b:c]on an instance passes one to__getitem__,__setitem__and__delitem__, also in an augmented assignment;slice(a, b, c)makes one;start,stop,stepandindicesread it; andseq[s]slices a list,str,bytes,tuple[T, ...]orrange, also as an assignment ordeltarget of a list. A slice is compared, hashed and written as CPython does (CLS-23).- A slice bound may be
Noneor anint | None, which stands for a missing bound, as initems[start:]withstart = None(DAT-12). - An operation on a variable of a union with an iterator, a file, a module
or a traceback member, such as
Iterator[int] | list[int], tests the object's kind; members TyPy cannot tell apart, such as two iterators, are planned for 1.0 (TYP-14, TYP-19). - The truth of an instance comes from the
__bool__, or else the__len__, of the object's own class, also where the variable's type is a base with neither or a union, and inanyandall(CLS-24). - A static or class method of a generic class called through the class
takes the type arguments from its arguments, as in
Box.wrap("a"), or from the class, as inBox[int].make(3), and runs that copy's method (GEN-01). - A protocol as the type of a variable, an attribute, a result or a
container item, such as
shapes: list[Shape], and of a parameter of__init__or another special method. The value holds an instance of any class that satisfies the protocol; a method call, an attribute read,==,lenandprintreach the object's class. A class derived from a protocol, a protocol's properties, static and class methods and class variables, assigning an attribute through a protocol value, and a built-in value held as a protocol are planned for 1.0 (GEN-10, GEN-17, ADR-0041). - A generic method that overrides one with as many type parameters: a call through the base runs the copy of the object's class's method for the same type arguments. Other overrides of or by a generic method are planned for 1.0 (GEN-09, GEN-16).
- A class method with type parameters of its own, or with a parameter that names a protocol, called through its class. Through an instance, and type parameters of a special method or a property, are planned for 1.0 (GEN-09, GEN-16).
- A method of a generic class with type parameters of its own,
def paired[U](self, other: U) -> tuple[T, U], takes the class's type arguments from the instance and solves its own from the arguments (GEN-09). - A class derived from a copy of a generic class,
class IntBox(Box[int]):, and a generic class derived from one for its own type parameters,class Pair[T](Box[T]):, whose copies derive from the matching copy. Class methods and dataclass fields inherited through a copy are planned for 1.0 (GEN-08, GEN-15, ADR-0040). - A generic class with a base of the program,
class Box[T](Base):: every copy derives fromBase, takes its methods and may stand where aBaseis expected.isinstancewith a generic class does not narrow a variable of a base's type, and the comparison methods of a generic dataclass derived from a dataclass, which need that, are planned for 1.0, with generic exception classes and generic protocols (GEN-08, GEN-12 to GEN-14, ADR-0040). - Class variables and defaults in the body of a generic class. Every
copy, such as
Counter[int]andCounter[str], shares them, as every instance shares them in CPython, and a generic dataclass gets__match_args__. One whose annotation names a type parameter of the class, such aslast: T | None = None, is planned for 1.0 (GEN-08, GEN-11). - A method called through a class with the instance first, such as
Shape.describe(square), runs the method that class holds or inherits, as in CPython. In__init__,Base.__init__(self, ...)does whatsuper().__init__(...)does and counts the base's attributes as assigned (CLS-06). - A generic function or class of another module, imported by name or
used through its module as
tools.first(items)ortools.Box[int]. Its copies read the names of the module that defines it (GEN-07).
Changed¶
- Lists, dicts, sets, strings and exceptions that do not outlive their function are made in its frame from 1.0, as MEM-10; in 0.5 MEM-03 covers instances of the program's classes.
list.sortandsortedcompare the items CPython 3.15 compares, in its order, so a__lt__that prints or raises shows the same calls, and a sort a comparison ends leaves the list as CPython leaves it. TyPy's own merge sort compared other pairs (OI-27).
Fixed¶
==and!=take optional values, as CPython does:Noneequals onlyNone, and two values compare as their type does. A dataclass with an optional field, whose__eq__compares its fields, was refused with E0407 (EXP-06, CLS-05).- A frozen dataclass whose field holds a
list,dictorsetinside a tuple, or through atypealias, compares as CPython does and has no hash; it was refused with E0413 (CLS-16). slice.indicestakes a length of any size, as CPython does; a length past 64 bits raisedOverflowError(CLS-23).- Printing a string with a surrogate writes it as CPython does in UTF-8
mode: standard output writes U+DC80 to U+DCFF as bytes, so a stray
byte of
sys.argvor of standard input is written back, and raisesUnicodeEncodeErrorfor any other surrogate; standard error and the report of an uncaught exception write\ud800. TyPy wrote?for each (LEX-10). encodewithsurrogateescapestarts itsUnicodeEncodeErrorat the first character it cannot escape, as CPython does, not at the start of the run (LIB-03).- A function that returns before a later loop over
dict.items(),keys()orvalues(), or a later comprehension over one, no longer leaks a view object of 24 bytes (CST-03). - A module-level statement that can call a function or a class before
the import that binds it has run is E0306, as one before its
defis. TyPy called it anyway, where CPython raisesNameError(TYP-12). - A function or a class that imports bind more than once, such as
from first import runand laterfrom second import run, one in each branch of anif, or two lazy imports, is called as the import that ran last bound it, and a name an import inside a block binds raisesNameErrorwhen that import has not run. TyPy called the last one in the source wherever the name was used, even before any import ran (MOD-12, ADR-0036). - A name an import binds to a function or a class that the module also
defines with
deforclassor assigns as a variable is E0202, as a seconddefis (STD-04). - An
OSErrorsubclass with an__init__of its own starts with no arguments, as CPython'sOSError.__new__leaves them toOSError.__init__:Quiet("q")isQuiet()withargs()unless its__init__callssuper().__init__, where TyPy kept("q",)(EXC-14). argsof aKeyErrorthe runtime raises holds the missing key itself, as CPython's does:(1,)ford[1]and(('a', 1),)for a tuple key, where TyPy held the text of itsrepr,('1',). The empty-set and empty-dict errors hold their message without quotes (EXC-11).- A sort,
min,max,in,indexandcountof objects of a class and of classes derived from it compare asa < banda == bdo, calling the right object's reflected method first when its class derives from the left one's, as CPython does; TyPy called the left object's method alone (CLS-07, CLS-22). - A comparison whose right operand's class derives from the left
operand's calls the right operand's reflected method first, also when
the subclass inherits it, as CPython does:
A() < B()calls__gt__ofB, where TyPy called__lt__ofA(CLS-07). - An arithmetic operator on two instances of one class that defines only
the reflected method, such as
__radd__, raises CPython'sTypeError; TyPy called the reflected method (CLS-07). items[f()] %= valuesandmake().text %= valueswith a format that takes its values when the program runs evaluate the target's parts once, where TyPy refused them (SMT-01).- An operator whose right operand's class has no reflected method, such
as
__radd__, calls the one a class derived from it defines when the right object is of that class, also first when that class derives from the left operand's, as CPython does; TyPy refused it (CLS-07). - A static method of a generic class that names none of its type
parameters, such as
Box.count(), is compiled once and called through the class or an instance; TyPy stopped with an internal error (GEN-01). issubclass,super()held as a value, andproperty,staticmethodandclassmethodcalled as functions are refused as planned for 1.0 (CLS-19, CLS-36, FUN-05); TyPy named 0.4 and 0.5 for them.import collectionsis E0206, as for any module TyPy does not provide, and the help listsdataclassesamong the modules it provides (LIB-08).- A dataclass derived from a dataclass of another module named through
the module, such as
class Labeled(shapes.Point), takes the base's fields, as withfrom shapes import Point; TyPy left them out of its__init__(CLS-05). - A method of a generic class that assigns an attribute, such as
self.item = iteminput, compiles when a signature names a copy of the class, such asBox[int]; TyPy refused it with E0310, as if the type of the attribute were not known yet (GEN-03). - Calling a generic class of another module, such as
Box(3)afterfrom tools import Box, compiles; TyPy stopped with an internal error (GEN-07). - A subclass may redefine a static method, or a method as a static one; a call through an instance runs the one of the object's class, as CPython does (CLS-06, CLS-35).
- An override may take or return a type held otherwise than its base's,
such as
int | Nonewhere the base takesint; a call through the base reaches it through an adapter. With a default of its own for such a parameter it is planned for 1.0 (CLS-04, CLS-34). - An override may give a parameter another default than its base's; a call through the base that leaves the argument out takes the default of the object's class, as CPython does (CLS-04).
- An exception class may give its attributes defaults in its body, such
as
code: int = 1, which each exception holds until__init__or the program assigns them (CLS-11). obj.prop += vof a property calls the getter, then the setter with the result; TyPy left the statement out. A property is assigned through any expression, asmake().prop = value(CLS-06).x[k] += von an instance whose class has__getitem__and__setitem__calls them, withxandkevaluated once; TyPy left the statement out, and now refuses it with E0401 when the class has no__setitem__(CLS-07).
0.4.0 - 2026-11-15¶
Added¶
- Single inheritance between classes of the program: a class may derive
from a class defined before it, named by its name or as
module.Class, and holds its base's attributes and methods. An instance is accepted wherever its base is, as an argument, in a variable, in alist[Base]and as aBase | None, andtype(),str,reprandprintuse its own class. A subclass may declare an inherited attribute again with the same type (CLS-04, ADR-0021). - Overriding methods: a subclass, including an exception class, may
define a method of its base again, and a call runs the method of the
instance's own class, also for
for,nextandwith. An override is checked against the base method as type checkers check it, E0404 otherwise; one that changes a default, or takes or returns a type held differently, such asint | Noneforint, is planned for 0.5 (CLS-04, CLS-13, ADR-0021). super()in any method:super().name(...)andsuper(Class, self)call the nearest base's method, andsuper().__init__()in a class whose bases have no__init__does nothing, asobject.__init__does. Outside a method it is E0414 (CLS-14). It comes after a subclass assigns its own attributes when the base's__init__uses the instance, which could run an override that reads them, E0309 otherwise (CLS-04).isinstancewith a class of the program, a built-in type or an exception class, or a tuple of them; a variable narrows to the tested class where the test holds, also after anifthat returns and in the right operand ofand. A class held in a variable andissubclassare planned for 0.5 (CLS-09, TYP-07).- Class variables,
name = valueandname: ClassVar[T] = valuein a class body, read through the class or an instance and assigned through the class; and attribute defaults,name: T = value, which each new instance starts with (CLS-11, ADR-0024). - Comparison methods
__eq__,__ne__,__lt__,__le__,__gt__and__ge__, and__hash__: operators call them, with CPython's reflected methods and the subclass's method first, and lists, sets, dicts,in,sorted,minandmaxcall them through the class's type object. A class with__eq__and no__hash__has no hash (CLS-07, ADR-0026). @dataclassfromdataclasses, witheq,orderandfrozenandfield(default=...): it writes__init__,__repr__,__eq__and the ordering methods as CPython does, and refuses what CPython refuses, such as a mutable default. The hash of a frozen dataclass anddefault_factoryare planned for 0.5 (CLS-05, LIB-06).- Unions, such as
int | str,str | list[int] | NoneorCircle | Square: a union of objects is held as the object itself, and any other with a tag that names its member, so anintstored in anint | strallocates nothing. A union can be passed, returned, stored, printed, written withstrandrepr, given totype()and tested for truth.isinstancenarrows it in both branches, and a union of classes that share a base has that base's attributes and methods. Any other operation on a variable that holds a union, such asvalue.upper(),len(value)orvalue + value, is checked for each member and runs the one for the object's member. Lists, sets and dicts of a union compare and hash each item as its member, so1and1.0are one key (TYP-14, TYP-07, ADR-0027). - Generic functions written with PEP 695 type parameter lists, such as
def first[T](items: list[T]) -> T, with bounds,[S: Shape], and constraints,[N: (int, float)]. A call takes the types from its arguments, and TyPy compiles one copy of the function for each set of types, so a generic call costs what a written-out call does.TypeVarandGenericare E0202; a function that would need copies without end is E0428. Calling a generic function of another module is planned for 0.5 (GEN-07), and*Ts,**Pand defaults for 1.0 (GEN-01 to GEN-03, GEN-06, ADR-0023). - Generic classes,
class Box[T]:, made byBox(1), whose types come from__init__'s arguments, or byBox[str]("a"), and namedBox[int]in annotations. Each copy holds its attributes in place, and answers as the generic class:type(Box(1)) is Boxandisinstance(Box(1), Box)hold. A generic class with a base, a class derived from one, and its class variables and defaults are planned for 0.5 (GEN-01, GEN-03, GEN-08, ADR-0028). - Protocols:
class Shape(Protocol):fromtypinglists methods and attributes, and any class that has them satisfies it. A parameter typed with a protocol, also insidelist[Shape], compiles to one copy for each class it is called with, and[S: Shape]bounds a type parameter by one. A class that falls short is E0404, naming the member; calling a protocol andisinstancewith one are E0401. A protocol as any other type, as a base, or with properties, static and class methods or class variables is planned for 0.5 (GEN-04, GEN-05, GEN-10, ADR-0023). ...alone as a statement does nothing, aspassdoes.opentakes a file descriptor, giving a file whosenameis thatint, andclosefd, with CPython's errors (LIB-14).opentakes a mode held in a variable, which opens a text file and is checked with CPython's errors when the program runs; a binary mode in a variable raisesTypeError(LIB-14, ADR-0031).opentakes binary modes, which give aBufferedReader,BufferedWriterorBufferedRandom, or aFileIOwithbuffering=0, reading and writingbyteswith CPython's results and errors (LIB-14, ADR-0031).opentakes the modes"r+","w+","a+"and"x+", which read and write one text file as CPython's do (LIB-14).close()ofsys.stdin,sys.stdoutorsys.stderrcloses it, as in CPython: reading it, writing to it,input()andprint()then raiseValueError: I/O operation on closed file.(LIB-14).opentakesbuffering,encoding(utf-8,asciiorlatin-1),errors(strict,ignore,replace,backslashreplace,xmlcharrefreplaceorsurrogateescape) andnewline, with CPython's results and errors;buffering=1writes out each line (LIB-14).- Text files have
name,modeandclosed, and the methodsfileno,isatty,readable,writable,seekable,seek,tellandtruncate, with CPython's results and errors; a file opened with"a"starts at its end (LIB-14). - Names a module binds by a lazy import can be used from another module,
m.x = vassigns through a lazily importedm, and a variable may be bound by more than one lazy import; each runs the pending import first, as CPython does (MOD-11). A function or a class bound by two lazy imports is planned for 0.5 (MOD-12). format % valueswith a format that is not a literal, also through%=, and with atuple[T, ...]of values: the runtime reads the format and raises what CPython raises (LIB-11).OSErrorand its subclasses built with two to five arguments, read aserrno,strerror,filename,winerrorandfilename2, with the attributeserrno,strerror,filenameandfilename2.OSErroritself becomes the subclass forerrno, as in CPython. Other argument types are planned for 0.5 (EXC-14, EXC-16).argsof an exception andcodeof aSystemExit, where a program prints, formats, compares with==or!=, or tests them, andlen(error.args). Other uses, such aserror.args[0], are planned for 0.5 (EXC-11, EXC-13, EXC-15, ADR-0030).sys.stdin, a text file thatinput()reads too, andsys.maxsize,sys.maxunicode,sys.byteorder,sys.platform,sys.getrecursionlimitandsys.setrecursionlimit. The recursion limit is kept forgetrecursionlimit; recursion still stops at the stack's limit (LIB-13, FUN-02).sys.version,sys.hexversionandsys.version_inforeport CPython 3.15.0, whose behaviour TyPy follows.sys.version_infois compared with a tuple ofints, indexed and read by field; as a value of its own it is planned for 0.5 (LIB-13, LIB-16, ADR-0029).math.fsum,math.dist,math.prod,math.sumprod,math.gammaandmath.lgamma, with CPython's results to the last bit. The first four take iterables ofint,boolorfloatitems;prodoffloats with the default start andsumprodwith afloatareint | float, since CPython gives theintstart or 0 for no items. Items of a union and aboolstart are planned for 0.5 (LIB-12, LIB-15).- Methods with type parameters,
def pair[T](self, value: T), also static methods, in a class that is not generic. A call takes the types from the arguments afterselfand runs the copy for them. Type parameters of a method of a generic class, of a special method, a property or a class method, and of a method that overrides or is overridden are planned for 0.5 (GEN-01, GEN-09). FinalandFinal[T]fromtyping: a module or function variable, a class variable or an attribute that__init__declaresFinalis assigned only by its declaration, and any other assignment is E0414. AFinalwithout a value is E0408 (TYP-08).- The
typestatement at module level:type Name = annotationmakesNamestand for the annotation in the module's annotations, and may name a class defined below it, as CPython reads the value late. An alias may take type parameters,type Pair[T] = tuple[T, T], andPair[int]stands for its value withintin place ofT. An alias of another module, read as a value, defined inside a function, a class or a block, or with a bound on a type parameter is planned for 0.5 (SMT-10, SMT-12). - Container methods:
len(x),x[k],x[k] = v,del x[k]andv in xcall__len__,__getitem__,__setitem__,__delitem__and__contains__, and truth tests,anyandallcall__bool__, or test__len__against zero. A negative__len__raisesValueErroras in CPython (CLS-07). - Arithmetic methods: the binary operators call
__add__,__sub__,__mul__and the others, with their reflected forms such as__radd__;-x,+x,~xandabs(x)call__neg__,__pos__,__invert__and__abs__; andx += yrebindsxtox + y. The in-place methods such as__iadd__are planned for 0.5 (CLS-07). @classmethod:Class.name(...)passes the class, socls(...)in an alternative constructor makes an instance of the class the call names, as in CPython; TyPy compiles a copy for each class of the module that has it (CLS-06, ADR-0025).@staticmethod, called through the class or an instance, and@propertywith its@name.setter: reading the attribute calls the getter of the instance's class, and assigning it calls the setter. A property without a setter cannot be assigned (CLS-06).- An exception class may derive from an exception class imported from
another module, as
from errors import AppErrororerrors.AppError(CLS-03).
Changed¶
- Allocation on the stack is planned for 0.5 (MEM-03), with the benchmarks that measure what it gains.
- A class decorator other than
@dataclassis planned for 1.0 with the other user-defined decorators (FUN-06), not for 0.4. open(..., encoding="csutf8")is E0404, as forstr.encode: CPython 3.12 does not know the name, so its result depends on the version. Write"utf-8"instead.- A binary mode with a
bufferingthat is not a literal is planned for 1.0 (LIB-19), since the value decides the class of the file. - The
openerargument ofopenis planned for 1.0 (LIB-18), since it takes a function as a value. - Importing a module inside a function of a module that it imports at module level is planned for 0.5 (MOD-13).
- Names of
typingthat TyPy does not give are planned for 0.5 rather than 0.4:Optional,Union,List,Dictand the other older names (LIB-17), andIteratorandIterableas values (TYP-17).typing.Anyandtyping.castare refused with E0202, since every value has one type (TYP-10). - A surrogate escape in a
strliteral, such as"\udcff", is planned for 0.5 rather than 0.4: string constants would have to carry code points instead of UTF-8 text through the whole compiler (LEX-10). -
The name of
except (A, B) as nameis the unionA | B, as type checkers read it, and no longer their common base; its attributes and methods are still the base's, and it can be stored in a variable declaredA | B(TYP-14). -
A base that is not
object, an exception class or a class of the program, such asintorlist, is E0201 with a message that names what a base may be, in place of "planned for TyPy 0.4" (CLS-04).
Fixed¶
- A class method with a parameter that names a protocol is E0201, planned for 0.5 (GEN-09); it was accepted and every call with a matching class was refused.
- A
forloop whose variable is aT | None, such as one bound earlier by a loop overNoneand"a", over items of typeTno longer stops the compiler with an internal error; the variable is notNonein the loop's body (CST-03, TYP-13). - A call that names one keyword twice, such as
print(1, sep="", sep=""), is E0103 with CPython'sSyntaxErrormessage,keyword argument repeated: sep; it used to compile, or report the wrong error (STD-01). - A
%format whose width is past a Cssize_tor whose precision is past a Cint, such as"%99999999999999999999d", is refused with CPython'swidth too bigorprecision too big(LIB-10). input()reads standard input as CPython does: a line that ends with\r\nor\rloses it, where it used to keep the\r(LIB-04).-
A truth test of a list, a set, a dict or
bytesin a recursive function, such asif not items:beforereturn f(items[1:]), stopped the compiler with an internal error (EXP-10). -
Repeating a list, a
strorbytesby a count from 2**62 up to the largest index-sized integer raisedOverflowError. An empty sequence now stays empty however many times it is repeated, and a longer one is refused as CPython refuses it. A list whose repeated length passes the address space now runs out of memory, which printsMemoryErrorand ends the program, where it used to raiseOverflowError(DAT-05, DAT-06, DAT-07). - Calling a class whose body declares an attribute that no
__init__assigns is E0309. The program used to compile and crash when the attribute was read, where CPython raisesAttributeError(CLS-01). - Calling a module variable that holds a value, such as an
int, from a function is E0401. The call used to be dropped, where CPython raisesTypeError(EXP-02).
0.3.0 - 2026-11-13¶
Added¶
openfor text files in UTF-8, in the modesr,w,aandx:read,readline,readlines,write,writelines,flushandclose, iteration over the lines, andwith. Reading translates newlines and decodes as CPython does, files still open are written out when the program ends, and errors are CPython'sOSErrorsubclasses with its text, such as[Errno 2] No such file or directory: 'notes.txt'.OSErrorand all its subclasses can be caught and raised. Binary and+modes, other encodings,seekand the file's attributes are planned for 0.4 (LIB-04, LIB-14, EXC-14, ADR-0019).- The
sysmodule'sargv,exit,stdoutandstderr,printwithfileandflush, andinput, which raisesEOFErrorat the end of standard input. An uncaughtSystemExitends the program with its code as the exit status and no traceback, as in CPython. Other names ofsysare E0201 when planned for 0.4 (LIB-13) and E0202 otherwise; the switches of lazy imports are E0202 (LIB-04, MOD-09). - The
mathmodule: its constants and its functions of numbers, with CPython's results to the last bit and CPython 3.15's error messages; a name newer than the program's Python floor is E0425.fsum,prod,sumprod,dist,gammaandlgammaare planned for 0.4 (LIB-05, LIB-12, ADR-0018). format % values, printf-style formatting of a string literal, with every conversion, flag, width, precision and*, and%(key)swith a dict, giving CPython's results. A format that does not fit its values is E0427 with CPython's message; a format that is not a literal is planned for 0.4 (LIB-10, LIB-11).typy explain CODEprints what a diagnostic means, the rule it enforces, a program that gives it and the corrected program; the troubleshooting page shows the same programs, and the documentation test runs them (CLI-10).- Warnings, where CPython warns while compiling: W0101 for an invalid
escape sequence such as
"\d", with the doubled backslash as its fix, and W0301 forassert (test, "message"), which is always true. They never fail a build unless--deny-warningsis given (DIA-07, DIA-08, ADR-0017). --error-format=jsonwrites each diagnostic as one JSON object per line, with the same keys every time, for editors and CI (DIA-05).typy.tomlbeside the main file setspython-floorandmodule-paths, the directories where imports look for modules after the main file's directory;--python-flooroncheck,buildandrunoverrides the file. A setting that is not valid is E0107 at its line, with exit status 2 (CLI-07, CLI-12, MOD-01).- Lazy imports:
lazy import mandlazy from m import namewith the Python floor 3.15, and a module-level__lazy_modules__at every floor. The module runs at the first use of a name, an error it raises reaches that use, and the next use runs it again. Using such a name from another module is E0201, planned for 0.4 (MOD-06 to MOD-08, MOD-11). Iterator[T]andIterable[T]annotations fromtypingorcollections.abc, andTracebackTypeandModuleTypefromtypes. AnIterable[T]takes any built-in iterable or iterator ofTand keeps the object, so a list passed as one can be read twice (TYP-15, CST-10, MOD-10).- A truth test,
notorbool()of a value whose truth TyPy cannot know is E0304 everywhere, not only in a condition (EXP-10). make benchtimes the release-built compiler on generated 10,000-line projects, in one file and in 200 modules, against the budgets of NFR-04, NFR-05 and NFR-14, and checks that checking time grows linearly with the number of modules; CI runs it.- Programs of several modules:
import m,import a.b as candfrom m import namefor functions, classes, module variables and submodules, packages with__init__.py, and relative imports. Each module runs once, at its first import, and runs again at the next import when its code raised. A module object prints as<module 'm' from 'm.py'>, with the path from the main file's directory (SMT-07, MOD-01 to MOD-03, MOD-10). - E0206 for a module the program does not have, E0422 for a circular import at module level with each import shown, and E0425 for a name a module does not define; standard library modules TyPy provides later are E0201 (MOD-05, LIB-08).
globalin a function, and functions that read the variables of their module. A read before the module binds the variable raises CPython'sNameError, and CPython'sSyntaxErrors forglobalare E0103 (SMT-08).NameErrorandImportErroras built-in exception classes (EXC-01).raisewith an exception or an exception class, andraise ... from causeandraise ... from None. An uncaught exception prints its cause or its context first, with CPython's line between them (SMT-06, EXC-04, STD-05).- The built-in exception classes as values, annotations and calls, with
CPython's bases, so a
KeyErrormay be stored where aLookupErroris declared;NotImplementedErrorandAttributeErrorare new (EXC-01, EXC-02, EXC-10). str,repr,printand f-strings of an exception give CPython's text, computed from its arguments;reprof aUnicodeDecodeErrorshows its five arguments (EXC-08).- Exception classes of your own: a class derived from a built-in
exception class, or from such a class defined before it, with
attributes, methods and its own
__init__,__str__and__repr__. Calling it keeps the arguments passed by position as the exception's arguments, andsuper().__init__(...)in__init__calls the base's.exceptcatches it by any of its bases, andiscompares exceptions (CLS-03, CLS-13, CLS-14, EXP-08). - Assigning a list to a slice of a list,
xs[a:b:c] = items, with CPython's results: a simple slice grows or shrinks the list, and an extended slice takes exactly as many items or raisesValueError(DAT-13). delof list items, list slices with or without a step, and dict keys, with CPython's errors; E0421 fordelof a variable, an attribute or part of a tuple,strorbytes(SMT-05).isandis notbetweenboolandbool | Nonevalues, such asdone is Trueorflag is False.True,FalseandNoneare each a single object, as in CPython, so the result is that of==(EXP-08).dict.keys()anddict.items()as sets:|,&,-and^with a set, another view or a list give a new set in CPython's order, and==,<and the other comparisons compare their items.dict.values()compares by identity, as in CPython (DAT-16).dict(name=value, ...), with or without a source, anddict.fromkeys(keys)anddict.fromkeys(keys, value), with CPython's order of evaluation (DAT-16).reversedof a dict, ofdict.keys(),dict.values()anddict.items(), from the last entry to the first; a dict that changes size raisesRuntimeError, as in CPython (DAT-16).rangeas a value and an annotation:len, indexing, slicing,in,==, use as a dict key or set item, and CPython's text.for,reversed,iterandnextread it, and its bounds may be of any size (DAT-17).with, with one or more context managers andastargets, calling__exit__on every way out of the body; a true result of__exit__suppresses the exception. The parameters of__exit__may be left without annotations, and its traceback is an object that holds no frames (CST-05, CST-10).- E0420 for
withon a value whose class has no__enter__and__exit__(CST-05). forover an instance of a class that defines__iter__and__next__, which ends when__next__raisesStopIteration(CST-08).iter()andnext(), with or without a default, for lists, tuples,str,bytes, sets, dicts and views of dicts, and for classes with__iter__and__next__, with CPython's iterator behaviour: a list iterator sees appended items, and a set or dict that changes size raisesRuntimeError(CST-09).assert testandassert test, message, which raiseAssertionErrorwhen the test is false in every build mode, evaluating the message only then; what the test shows holds after it (SMT-04).finally, which runs on every way out of atry: falling through,return,break,continueand an exception, which keeps going after it. E0419 refuses areturn,breakorcontinuethat would leave afinallyblock, as CPython 3.14 warns about it (CST-04, EXC-06).trywithexceptclauses andelse:except C,except (A, B),except C as nameand a bareexcept. A clause catches its classes and every class derived from them, the name afterasis deleted when the clause ends, and a bareraiseinside a clause re-raises the exception. An exception raised while another is handled keeps it as its context, and an uncaught one prints it first (CST-04, EXC-01, EXC-04, EXC-07, EXC-09).- E0418 for an
exceptclause that names something other than exception classes (EXC-09). - E0415 for
raiseof a value that is not an exception, E0416 for a bareraiseoutside anexceptclause, and E0417 for a call ofUnicodeDecodeErrororUnicodeEncodeError(EXC-07, EXC-12).
Changed¶
- The last use of a variable moves its value into an assignment, a
display,
append,insert,addor a dict entry, and a new value such as a call's result goes into a collection without being counted, so building a collection in a loop does no reference counting of its items (MEM-09). --releaseand--release-smallbuilds leave out debug information; a static musl hello world is about 30 KB (CLI-05, NFR-01).
Fixed¶
- A format specification on an exception, such as
f"{error:>5}", raisesTypeErrornaming the exception's own class, as CPython does; it namedNoneType. - A deeply nested program no longer crashes
typy; it aborted on 1000 nested brackets. Brackets nested past 200 and blocks past 99 are E0103 with CPython's messages, and expressions or statements nested past 25000 are E0103; everything CPython compiles still compiles (LEX-11, ADR-0020). - A function of many blocks, such as a long
elifchain, compiles in time and memory in proportion to its size; 20000elifclauses ran out of memory. print(..., file=f)inside anexceptclause compiles; it failed with E9001.- An import inside a function, or a lazy one, no longer makes a circular import with a module that imports the importing module back at module level; it gave a false E0422 (MOD-05, OI-21).
- A function whose only
tryhas a body that cannot raise compiles; it failed with E9001. - A
\uor\Uescape of a surrogate in astrliteral is E0201, planned for 0.4 (LEX-10); it gave U+FFFD instead of the surrogate. - Programs call the C library's maths functions, as CPython does, and
not the copies in the runtime archive, whose
cbrtdiffered in the last bit. typy runbuilds again after the runtime archive changes, since the cache key now covers the archive as well as the compiler.-
type(m)of a module, anIterable[T]or a traceback gives its type object; it stopped the compiler with E9001 before. -
typy runno longer reuses an executable built from other versions of the program's modules or by another build of the compiler: the cache key covers every file of the program and the compiler executable. - A list, set or dict display, a comprehension, or a
list,set,tupleordictcall is accepted where an optional collection is expected, such asitems: list[int] | None = []or an argument of typelist[int] | None; it stopped with E9001 or E0410. - A function that returns a value on both branches of an
ifandelse, with nothing after them, compiles; it stopped with E9001.
0.2.0 - 2026-11-10¶
Added¶
- Tuples: displays such as
(1, "a"), annotations such astuple[int, str]andtuple[()], items read at a literal position such aspair[0]orpair[-1],+,len, comparisons item by item, truth tests,strandrepr, and tuples as arguments and return values (DAT-08, TYP-06). - Unpacking assignment into names and nested tuples of names, such as
a, b = b, aandx, (y, z) = t(SMT-02). - Lists of
int,float,bool,strand lists: displays such as[1, 2], annotations such aslist[str], an empty[]where an annotation, a return type or a parameter gives its type, items read and assigned at positions counted from either end withIndexErroroutside,append,len,inandnot in,==, truth tests,strandrepr, andforover a list. Two names bound to one list share it (DAT-07, DAT-11, TYP-05, EXP-07, CST-03). A list stores each item in eight bytes, so alist[float]holds raw doubles (MEM-02), and a millionintitems fit in 8.5 MB (NFR-13). - Slices of strings and lists, such as
text[1:4],xs[::-1]andxs[-2:], with Python's defaults and clamping, andValueErrorfor a zero step (DAT-12). - The list methods
pop,insert,extend,remove,index,count,clear,copyandreverse, with CPython's errors (LIB-03). +and*on lists, ordering of lists with<,<=,>and>=,xs += ysandxs *= nchanging the list in place, and augmented assignment of a list item such ascounts[i] += 1(EXP-02, EXP-06, SMT-01).- An empty
[]in a comparison takes the type of the other operand, soxs == []needs no annotation, and one inside a display takes the type of the other items, as in[[1], []](TYP-05). sorted, withreverse,list.sort,sum, with an exact result forintitems and CPython's compensated result forfloatitems,any,all, andminandmaxof a list, withdefault(LIB-02, LIB-03).sumof alist[float]takes a start such as0.0, because CPython returns theint0 for an empty list without one. Thekeyargument arrives with function values in 1.0 (FUN-05).- Lists of tuples and of
None, such aslist[tuple[int, str]], with every list operation. A tuple is stored inline in the list, so a million pairs ofintvalues take 16 MB (DAT-07, MEM-02). list(),list(xs), andlistof astr,enumerate,ziporreversed;sorted,min,max,sum,anyandalltake those sources too (LIB-02).inon astr, a substring test, and on a tuple, and slices of a tuple with literal bounds such aspair[1:](EXP-07, DAT-12).tuple[T, ...], a tuple of any length, withtuple(source), indexing, slicing,in,len,+,*, comparisons,count,indexandfor. A tuple such as(1, 2)is accepted where atuple[int, ...]is expected, andforgoes over a tuple whose items have one type (DAT-14, CST-03).bytes: literals such asb"a\x00",bytes(),bytes(n)andbytes(values), items asintvalues, slices,len,+,*, comparisons,in,for, andstrandrepras CPython writes them (DAT-06).- The methods of
bytesthatstrhas too,findtojoin,strip,replace, padding,upper,lower,swapcase,capitalize,titleand theistests, with CPython's ASCII meaning, andbytes.hex(LIB-03). str.encode,bytes.decodeandbytes(text, encoding, errors)with the codecsutf-8,asciiandlatin-1under all their CPython names, and the error handlersstrict,ignore,replace,backslashreplace,xmlcharrefreplaceandsurrogateescape, raisingUnicodeEncodeErrorandUnicodeDecodeErrorwith CPython's messages (LIB-03, EXC-02).- The
strmethodsfind,rfind,index,rindex,count,startswith,endswith,split,rsplit,splitlines,partition,rpartition,join,strip,lstrip,rstrip,removeprefix,removesuffix,replace,center,ljust,rjust,zfill,expandtabsandisascii, with arguments by keyword where CPython allows them (LIB-03). - The
strmethodsupper,lower,casefold,swapcase,capitalizeandtitle, andisalpha,isalnum,isdecimal,isdigit,isnumeric,isspace,isupper,islower,istitle,isidentifierandisprintable, from CPython 3.15's Unicode 17.0 data, with CPython's final sigma and its title case of words such asthey're(LIB-03, OI-15). round, with and withoutndigits, rounding half to even on the exact value as CPython does, soround(2.675, 2)is2.67(LIB-02).forover the characters of astr, and overenumerate, withstart,zip, withstrict, andreversedof lists and strings, nested as inenumerate(zip(a, b)), with CPython's errors (CST-03, LIB-02).- Sets of numbers,
bool,None,str,bytesand tuples of them: displays such as{1, 2}, annotations such asset[int],set()andset(source),in,len, truth tests,strandrepr,for,|,&,-and^and their in-place forms,==and the subset comparisons, and the methodsadd,remove,discard,pop,clear,copy,union,intersection,difference,symmetric_difference,update, the_updatemethods,issubset,issupersetandisdisjoint, which take any iterable of the items, and several where Python takes several (DAT-10, DAT-15, LIB-03). A set hashes its items as CPython does and iterates and prints them in CPython's order (ADR-0010). A list or a set as an item of a set is rejected, since it has no hash.removeof a missing item andpopof an empty set raiseKeyError, and a set that changes size while a loop reads it raisesRuntimeError. set()in a comparison takes the type of the other operand, as[]does, sos == set()needs no annotation (TYP-05).- Dicts: displays such as
{"a": 1}, annotations such asdict[str, int],{}anddict()where an annotation or the other operand of a comparison gives the type,dict(source)from a dict or from(key, value)pairs,d[k]withKeyErrorfor a missing key,d[k] = vandd[k] += v,in,len, truth tests,strandrepr,forover a dict,|,|=,==and!=, the viewskeys(),values()anditems(), which follow the dict as it changes, and the methodsgetandsetdefaultwith a default,pop,popitem,update,clearandcopy(DAT-09, LIB-03). A dict keeps insertion order, leaves holes where entries were removed until it is resized, and raises CPython'sRuntimeErrorwhen it changes while a loop reads it. Sets take a dict wherever they take an iterable, with CPython's steps for a dict (DAT-15). - List, set and dict comprehensions, with several
forclauses andifconditions, each in its own scope, so a comprehension variable does not leak and the first source is read in the enclosing scope, as in CPython (EXP-12). - Optional values: annotations such as
int | NoneandNone | str,Noneor a value where one is expected, in variables, parameters, defaults, returns, lists, sets, dicts and tuples,is Noneandis not None, truth tests,strandrepr, anddict.get(key)without a default (TYP-06). A variable narrows to its value where anis not Nonetest, anis Nonetest that failed, a truth test, or an assignment shows it is notNone, and using it unnarrowed is rejected with a hint (TYP-13).Nonecosts no memory: it is held in a value the type never takes (ADR-0011). - A display with
Noneamong its items, and a conditional expression with aNonebranch, have the optional type, such aslist[int | None]. range(...)andreversed(range(...))wherever an iterable is read: in comprehensions,list,set,dict,sum,sorted,enumerate,zipand the set methods, as well as infor(CST-03).- Classes:
classstatements with__init__, methods, attributes declared in the class body or assigned in__init__, and instances in variables, parameters, returns, lists, sets, dicts and tuples (CLS-01). Assigning or calling a name the class does not have is rejected (CLS-02), and so is any use ofselfin__init__before every attribute is assigned.__str__and__repr__write instances forprint,str,reprand containers, and a class without them is written as CPython writes it (CLS-08). Instances are equal only to themselves, hashed by identity and compared withis. A signature names a class defined below it, or its own class, in quotes, such as"Node | None". - Every type has a type object whose bases end at
object, the base of each class, ready for inheritance andisinstancein 0.4 (CLS-10, ADR-0012). type(x)gives the type object of a value, and class names and the built-in type names, such asintanddict, are type objects as values. A type object prints as<class 'int'>or<class '__main__.Point'>, has__name__, compares withisand==, and can be a dict key; the annotationstypeandtype[int]hold one (CLS-12).- f-strings, with
!s,!rand!a,{x = }, nested fields in a format specification, and the whole format specification mini-language forint,bool,floatandstr: fill, alignment, sign,z,#,0, width,,and_grouping, precision and the typesb,c,d,o,x,X,n,e,E,f,F,g,G,%ands. Every result and error message matches CPython 3.12 to 3.15 on a table of 4,628 cases, andfloatdigits are rounded exactly (LEX-07). - Passing a variable or a constant as an argument no longer counts a
reference, and
return namemoves the variable's value to the caller (MEM-04). An argument read from a container is kept alive for the call, so a callee that empties the container still sees it, as in CPython. - User documentation in
docs/user: getting started, a language guide with one page per area of the specification, and a troubleshooting page for every diagnostic code. Every Python sample is checked by the test suite, and an accepted one must print what CPython prints (DOC-01 to DOC-04).
Changed¶
%formatting of strings is planned for 0.3 (LIB-10), anditerandnextfor 0.3 (CST-09); an f-string formats a value now. An annotation of a generic type other thanlist,dict,set,tupleandtype, such asfrozenset[int], is reported as not provided.- The runtime's size budget (NFR-02) is measured on the runtime a hello world links, 10.3 KB, rather than on the whole runtime archive, so the runtime can hold the built-in collections without enlarging programs that do not use them (ADR-0009).
Fixed¶
- A program function named
rangeis called byfor i in range(...), as in CPython, instead of the builtin (CST-02). - A traceback shows an entry repeated in a row at most three times, then
[Previous line repeated N more times], as CPython does, so aRecursionErrorwrites a few lines instead of one for each frame (STD-05).
0.1.0 - 2026-11-07¶
The first release. TyPy 0.1 compiles programs made of module-level
functions and statements over int, float, str, bool and None to
native executables for x86_64 Linux, with glibc or statically with musl.
Each program it accepts prints what CPython 3.12 to 3.15 prints. The
compiler needs glibc 2.39 or later and a C toolchain.
Added¶
- Engineering documents: research, requirements specification, use case and domain models, architecture, decision records ADR-0001 to ADR-0008, detailed design for 0.1, test plan and development guide.
- A development container with Rust 1.99.1, LLVM 23, musl, CPython 3.12 to 3.15 for conformance testing, and the documentation tools.
- The
typy-diagnosticscrate: source spans, diagnostic codes, the code registry and text rendering, with unit and property tests. - The
typy-sourcecrate: reading source files with the 16 MiB and UTF-8 checks, line and column positions, parsing with the program's Python floor, and TyPy's own syntax tree with its text dump. - The
typy-checkcrate: the 0.1 feature table, name resolution with Python's scoping, type inference within a function, definite assignment, and the typing rules for the operators and builtins of 0.1. Every rejection names its rule. - The
typy-tyircrate: TyIR's types, a function builder, a verifier that checks definitions by dominance and the types of every operation, and the text form for--emit=tyir. - The
typy-lowercrate: lowers a checked program to TyIR with reference counting, error returns throughinvoke, and the semantics of CPython for loops,and,or, comparison chains and the builtins of 0.1. - The
typy-codegencrate: turns TyIR into LLVM 23 IR, assembly and object code, with static immortal constants and traceback entries on raising calls;--release-smallmarks functionsminsize, as LLVM 23 has noOz. - The
typy-runtimecrate, without the standard library: object headers, reference counting,strobjects and their operations, exceptions with tracebacks and the uncaught-exception report, buffered output, the stack check andmain.make runtimebuilds the archive programs link. - Unlimited-size
intin the runtime: arithmetic,//,%and**with Python's floor rules, bitwise operators and shifts, comparisons, and conversion to and fromstrwithint()'s parsing rules and CPython's 4300-digit limit. Error messages match CPython's. floatin the runtime:/,//,%,**andabswith CPython's special cases;int / int,float(int)andfloat(str)rounded once to the nearest double; exactint(float)and exact comparison ofintwithfloat; andreprwith CPython's shortest digits and layout.- Every division by zero raises
ZeroDivisionError: division by zero, the wording of CPython 3.14 and later (OI-14). reprof a string escapes exactly the code points CPython 3.15 escapes, from Unicode 17.0 tables generated from CPython's own data (OI-15).chrandordin the runtime, with CPython's messages.int()andfloat()read decimal digits of every script, such asint("\u0661\u0662"), which is12.- The
typy-buildcrate: build requests, modes and--emitstages, and the link of an object file with the runtime archive throughccormusl-gcc. The executable appears whole or not at all; a missing toolchain program is E0701, a failed link E0702, and a missing runtime archive, or one from another TyPy version, E0703. - Diagnostics without a source location, such as a failed link.
- The
typycommand:typy check FILE,typy build FILEwith--emit,-o,--releaseand--release-small, andtypy run FILE -- ARGS, which keeps each build in a cache underTYPY_HOMEand runs it again without compiling. Exit status 0 on success, 1 for program errors, 2 for wrong usage and 101 for an internal error, which a panic also becomes. - The
typy-conformancecrate and a conformance suite of 89 programs intests/conformance/: each accepted program runs under CPython 3.12 to 3.15 and under TyPy in debug and release mode, with the same output, exit status and last line of standard error; each rejected program gets exactly its diagnostic code at its line and column.make testruns it. - Every accepted conformance program also runs linked with AddressSanitizer and LeakSanitizer and must show no report. A program that ends with an uncaught exception frees the exception before it exits, so it leaks nothing.
- The sanitizer run uses a runtime built with AddressSanitizer, so every
memory access the runtime makes is checked.
make miriruns the runtime's unit tests under Miri, andmake fuzzfuzzes the source, checking and lowering stages. - Continuous integration: the quality gate and the release archive on
every pull request, Miri and 30 minutes of fuzzing on demand before a
release, code scanning, dependency review, and monthly grouped Dependabot
updates. A tag
vX.Y.Zreleases the version after a maintainer approves it. make distbuilds a reproducible release archive of the compiler and its runtime archives, and runs a program with it unpacked.make checkmeasures branch coverage as well as line coverage and fails below 95 percent of either (NFR-11);make coverage-branchesruns that measurement alone, andmake test-int,make test-e2eandmake test-allrun one test level each.- Golden tests of every text stage of
--emitand of rendered diagnostics intests/golden/;make blessrewrites them. - End-to-end tests for a missing or failing C toolchain, an empty program,
the 16 MiB limit, a file that is not UTF-8, two builds at once, argument
forwarding by
typy run, and environment variables that must not change the output. - The stack check reads the stack pointer register, so
RecursionErroris raised in time also when locals do not live on the machine stack. - The runtime archive is built for musl as well as glibc, and
make checkchecks its size: 40.3 KB, and 29.8 KB without large integers (NFR-02). A hello world built with--release-smalland linked statically with musl is 75 KB (NFR-01). - E0106 when an output file cannot be written; the linker reports a directory it cannot write with E0106 instead of E0702.
- The
typy-drivercrate: runs loading, checking, lowering, code generation and linking in order, and stops after the stage--emitnames.--emit=typed-astwrites every node with its position and type, and--emit=tyirleaves out theincanddecthat--emit=tyir-memshows. - A quality gate,
make check, that checks formatting, runs Clippy and the tests with at least 95 percent line coverage, lints the documents, checks for non-ASCII text, checks that every requirement has a row in the test plan, and checks that every diagram is rendered from its source.