Repository navigation
Releases
Pystachy v0.7.0-rc.1
Pystachy v0.7.0-rc.1 freezes the v0.7.0 feature set for final qualification. Since alpha.3, objects of class templates read a class attribute's current value, and NamedTuple and integer or string enum classes that define only __eq__ keep the builtin !=. Pystachy remains an experimental compiler for a typed subset of Python.
Corrections since alpha.3
- Objects of a class template, and of a subclass of one, read a class attribute with its current value after the program rebinds it through the class, as in
Box.limit = 10orcls.limit += 1, until they assign it themselves. Alpha.3 kept the original value. (#1724, #1726, #1727, typing) - A
NamedTuple,IntEnum,IntFlagorStrEnumclass that defines__eq__but not__ne__keeps the builtin!=, as CPython does:Pair(1) != ""isTrue. Previously!=inverted the class's__eq__. (#1738) - The
threadingmodule's dynamicAnyopt-in is recorded as a contract, with a test of the timers and argument packs that need it. (#1734, dynamic Any boundaries)
Features carried from the alphas
- Classes and typed IR: nested and local classes, subclasses of
list,dictandcollections.abcclasses,__getattr__,intwherefloatis annotated, most ofenum, and the typed IR as a checked text form with source locations. Alpha.1 - WebAssembly and installation: an experimental WebAssembly target for snippets from a source checkout, fewer library modules that need dynamic
Any, andpystachy doctor. Alpha.2 - Errors, templates and verification: CPython-style tracebacks in executables, subclasses of class template specializations, tuples in closed unions,
==that falls back to the reflected method and identity,pystachy check --semantic, generators and callbacks in the direct Wasm backend, and more typed IR verifier checks. Alpha.3
Known limits
Two wrong results from alpha.3's class changes remain for the next candidate. An object of a list or dict subclass reaches another class's __eq__, __ne__ or ordering method as a plain list or dict, where alpha.2 rejected the program (#1739). A class method that assigns cls.x, called through an object of a subclass of a class template, changes the base class's attribute instead of giving the subclass its own (#1744).
Dynamic Any and promoting integers remain experimental opt-ins, and the WebAssembly target runs only from a source checkout. Known issues that predate the alphas include star imports from packages without a top-level export list (#1513), reads of a builtin's name where a module global of that name is unbound (#1512), an except clause's as name that an import bound (#1514) and isinstance() tests against a second base class (#1602).
The verifier's allocation cost under GC stress and the remaining Lean report rejections are still tracked (#1644, #1643). The compatibility reference lists the documented deviations.
Moving the list and string core into runtime.py, Protocol and object storage, and the portable LLVM download wait for 0.8.0. Fixes found after this candidate ship in a second candidate or in v0.7.0.
Platforms
| Native archive | Requirements |
|---|---|
| Linux x86-64 / AArch64 | Ubuntu 24.04 or compatible glibc 2.39+ Linux; LLVM 18 |
| macOS arm64 / x86-64 | macOS 15+, Xcode Command Line Tools; LLVM 20 |
Archives and Docker run without Python; the hosted compiler needs Python 3.11+ and reports commit unknown when installed with pip. Full verification targets Linux x86-64 and ARM64 with CPython 3.13.16. Linux archives are not manylinux packages. This prerelease keeps the stable defaults at v0.6.1.
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.7.0-rc.1 for linux/amd64 and linux/arm64, with LLVM 18 included.
As a prerelease, this version does not move GitHub's latest release or Docker's latest tag.
Source commit: c0f7d7f6753b2c3c7b282feb81e520924d566813.
Pystachy v0.7.0-alpha.3
Pystachy v0.7.0-alpha.3 makes compiled executables print CPython-style tracebacks. It extends class templates and closed unions, and lets the experimental WebAssembly backend compile generators and callbacks directly. This is the last alpha of 0.7.0: its release candidates take fixes only. LLVM remains the default native backend. Pystachy is an experimental compiler for a typed subset of Python.
Errors and the command line
- An uncaught exception in an executable prints a traceback with the file, line and function of each frame, as CPython does.
buildnow gives a program's functions line tables, which the traceback reads;PYSTACHY_DEBUG_LINES=0leaves them out. Chained exceptions, macOS and Wasm still print only the final line. (#1710, errors and cleanup) pystachy check --semantic FILE.pycompiles a file without LLVM and reports its first error.pystachy buildaccepts-O0,-O1,-O2and-gafter the source file.pystachy doctorprints the runtime cache as an absolute path. The getting-started guide lists valid source that the pre-commit hook rejects. (#1693, #1694, #1691, #1690)
Typing and libraries
- A class can derive from a specialization of a class template, with a templated
__init__and template-typed fields. A closed union can hold one tuple type, and recursive aliases are named by their shape and type arguments. (#1707, #1716, #1698, #1699, typing) ==between an object and a value of another type calls the left operand's__eq__, then the reflected one, then compares identity, as CPython does. (#1706)- Enum classes held in class attributes,
sys.float_infoattributes in class bodies, andtyping.Pattern[str],Match[str]andIO[str]annotations compile.zlib.crc32()andzlib.adler32()are available. (#1686, #1665, #1674, #1687, #1668) - Fixes: star imports follow a conditional
__all__and a package's current exports.abs()of a nonnegative integer keeps its identity. Chained__class__()constructors compile in linear rather than exponential time. Thethreadingport releases discardedThreadobjects. (#1669, #1684, #1688, #1664, #1682)
WebAssembly from a source checkout
- The direct backend compiles typed callbacks and plain generators, keeps a generator's typed state across suspension, and dispatches static object callbacks through the module's table. Builtin container subclasses get wasm32 header layouts. (#1675, #1676, #1678, #1679, #1680, #1683, Wasm setup)
- Fixes under WASI: nested handlers unwind to the enclosing one, and
*argstuples andvars()fields keep the wasm32 layout. The collector traces whole pointer words, and zero-length writes no longer move file positions.float("-nan")andmath.fmakeep their signs. The Wasmtime runner forwards piped input, andWASM_EH=standardbuilds enable the reference types that Binaryen's exception conversion needs.wasm/check_corpus.pycompares the corpus with a list of explained differences. (#1695, #1696, #1677, #1705, #1708, #1709, #1681, #1697)
Verification
- Typed IR text carries a format version. With
PYSTACHY_IRCHECK=1, the verifier also checks that control flow is structured and proves reads of objects at narrower classes. (#1700, #1701, #1702, #1704) - The compiler infers its own types in one attempt, which the bootstrap now requires. Each dynamic
Anyopt-in in the library is recorded as a contract or as tracked debt. (#1714, #1713, dynamic Any boundaries)
Installation and limits
- Supported platforms are unchanged from alpha.2. The distributed Linux archives require glibc 2.39+ and LLVM 18. The macOS archives require macOS 15+, Xcode Command Line Tools and LLVM 20. (installation)
- Objects of a class template, and of a subclass of one, keep reading a class attribute's original value after the program rebinds it through the class's name; a release candidate will fix this. (#1724)
- Moving the list and string core into
runtime.py,Protocolandobjectstorage, and the portable LLVM download wait for 0.8.0. The verifier's allocation cost under GC stress and the remaining Lean report rejections are still tracked. (#1644, #1643)
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.7.0-alpha.3 for linux/amd64 and linux/arm64, with LLVM 18 included.
As a prerelease, this version does not move GitHub's latest release or Docker's latest tag.
Source commit: e124b71e1ef13dde1afad24bb747bb1621285262.
Pystachy v0.7.0-alpha.2
Pystachy v0.7.0-alpha.2 adds an experimental WebAssembly target for Python snippets, reduces the number of modules that need dynamic Any, and adds a command for diagnosing local installations. LLVM remains the default native backend. Pystachy is an experimental compiler for a typed subset of Python.
WebAssembly from a source checkout
- A Node host can compile once and rerun a snippet with fresh memory and tool grants. The optional Python host runs the same program routes on Wasmtime 51 with standard exception encoding and per-run fuel and memory limits. The direct backend reads finalized typed IR. When it encounters an unsupported operation, it reports the reason and can reuse the same compilation to build through LLVM/WASI. (Wasm setup and examples, #1641, #1642, #1654)
- Both routes support Python exception handlers across calls. Generators use the LLVM route. The direct backend supports static exception descriptors, masked 32-bit arithmetic, and typed JSON tool results. WASI error numbers can differ from Linux. Node's execution timeout covers instantiation and execution. Compilation and blocking native callbacks require separate supervision. (#1652, #1653, #1659, #1660)
- A complete typed IR text module can be read back into the same compiler and lowered to LLVM. The tool reports the state it cannot reconstruct, including extension entry points and LLVM debug line tables. (#1636)
Typing and runtime
- Closed unions support more arithmetic and container operations.
pathliband more of the JSON repair port compile without a module-level dynamicAnyopt-in. Arithmetic-only parameters in eligible kernels keep their unboxed representation. (#1632, #1648, #1650, #1651) - Reinitializing a list subclass from an iterator, checking a container subclass against collection ABCs, and falling back to builtin arithmetic when a subclass overrides another operator now follow CPython. (#1661)
- The JSON repair parser preserves mutable object and log aliases. Closed-union equality compares its active member with a promoting integer at full width. Integer members stored in recursive unions still fit in 64 bits. (#1655, #1656)
- The IR verifier reuses type bindings and checks optional reads and nullable union boxes. It accepts lengths of dictionaries, bytes, sets and variable-length tuples stored in an integer-or-string union. More fixed-width integer operations run in
runtime.py, and percent-format padding passes typed settings. (#1637, #1662, #1663, #1649, #1307, #1628, #1647)
Installation and limits
- Run
pystachy doctorto inspect the LLVM tools and runtime cache.pystachy --helpprints the available commands. A pre-commit hook checks staged Python files with Pystachy. (#1640, #1646, #1645) - The Linux source-build workflow checks glibc 2.28 on x86-64. The LLVM 18 JIT keeps nested exception handlers on AlmaLinux 8. The distributed Linux archives still require glibc 2.39+ and LLVM 18. The macOS archives require macOS 15+, Xcode Command Line Tools and LLVM 20. (#1633, #1667, installation)
- The compiler GC stress test retains the 7,000-allocation interval. The verifier's allocation cost and outstanding Lean report rejections remain tracked. (#1181, #1644, #1643)
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.7.0-alpha.2 for linux/amd64 and linux/arm64, with LLVM 18 included.
As a prerelease, this version does not move GitHub's latest release or Docker's latest tag.
Source commit: 4998521d28413c6e32506105f836b6db9afeb1d7.
Pystachy v0.7.0-alpha.1
Pystachy v0.7.0-alpha.1 starts the v0.7.0 series from v0.6.1. It compiles nested and local classes, subclasses of list, dict and collections.abc classes, and classes with __getattr__; accepts an int where float is annotated; fills in most of enum; and makes the typed IR a checked text form with source locations. Pystachy remains an experimental compiler for a typed subset of Python.
Classes
- A class statement in a class body, or in a function that runs at most once, makes a class with CPython's
__qualname__. (#1596, #1613) - A class may derive from
list,list[T],dictordict[K, V]as its one base; what it leaves to the builtin compiles to the builtin's own code,__missing__included. (#1558) - A class may derive from
collections.abcclasses such asMutableMapping,SequenceandSet, which inherit CPython's mixin methods, andisinstance()takes ABCs such asSized,IterableandHashable. (#1610) - A class's
__getattr__is called for the attributes its objects lack, and a secondary base's__init__may store attributes. (#1559, #1614) - Using a new object of an abstract class in the same expression, as
print(Half())does, raises CPython'sTypeError, where the compiler failed. (#1621)
Typing and library
- A variable, field or return annotated
floatholds anintit is given, as PEP 484 allows, and one annotatedintorstrholds anIntEnum,IntFlagorStrEnummember as it is. (#1550, #1592) enumaddsmember(),nonmember(),@verify(...)with its checks, flags'boundary=(STRICT,CONFORM,KEEP),show_flag_values(), theglobal_*()helpers and the functional API at the top of a module. (#1563)- With dynamic
Any,deque,bytearray,weakref.ref,MappingProxyTypeand thecollectionsmappings compare with other types as CPython's do. (#1599)
Typed IR and tools
- With
PYSTACHY_IRCHECK=1, the typed IR verifier checks each operand against its value's type, and a value read at another type is an explicitcastop; the Lean shape check proves that each value is defined before it is read. Every op records its source line, and a module prints as text with its classes and their fields. (typed IR, #1593, #1566, #1604, #1606, #1617, #1625) tools/annotate_ir.pyshows each source line with its typed IR and LLVM IR, andtools/rejection_survey.pylists several rejections of a program in one run. (#1565, #1549)- The hosted compiler is checked under CPython 3.11 to 3.15, and 13 more pyperformance benchmarks are ported (38 of 52). (#1626, #1619)
Known limits and platforms
Dynamic Any and promoting integers remain experimental opt-ins. The known issues of v0.6.1 remain (#1512, #1513, #1514, #1602). The compatibility reference lists the limits of the new class features and the documented deviations.
| Native archive | Requirements |
|---|---|
| Linux x86-64 / AArch64 | Ubuntu 24.04 or compatible glibc 2.39+ Linux; LLVM 18 |
| macOS arm64 / x86-64 | macOS 15+, Xcode Command Line Tools; LLVM 20 |
Archives and Docker run without Python; the hosted compiler needs Python 3.11+ and reports commit unknown when installed with pip. Full verification targets Linux x86-64 and ARM64 with CPython 3.13.16. Linux archives are not manylinux packages. Prereleases leave the stable latest unchanged.
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.7.0-alpha.1 for linux/amd64 and linux/arm64, with LLVM 18 included.
As a prerelease, this version does not move GitHub's latest release or Docker's latest tag.
Source commit: 41dffd36201e6655c2603b28a458300c864237f7.
Pystachy v0.6.1
Pystachy v0.6.1 fixes bugs that v0.6.0 shipped with: wrong isinstance() answers for Any values, a collector crash and runaway memory, and strict encodes that passed invalid UTF-8. It adds no features. Pystachy remains an experimental compiler for a typed subset of Python.
Fixes
- With dynamic
Any,isinstance()accepts aNamedTupleobject as atuple, and a tuple of types that holdsNoneraises CPython'sTypeError. A localtypethat holds the builtin, such as a parametertype=type, still makestype(None)meanNoneType; any other is rejected at compile time. (#1581) repr()of a set or frozenset that an element's__repr__prints again givesset(...), where it raisedRecursionError. (#1586)- A program that runs out of memory during a collection prints
MemoryError, runs itsatexitcallbacks and exits with status 1, where it could die of SIGSEGV. (#1585) - A
pyobjobject whose__sizeof__reports a size near 2**63 no longer stops collection for the rest of the run. (#1584) - A str read from a file with an overlong UTF-8 sequence counts each of its bytes as a character in encodes too, as
len()does: a strict ASCII encode raisesUnicodeEncodeError, where it returned the bytes. (#1587) Decimal's//,%anddivmod()take the time their operands' sizes need at any precision; atMAX_PRECthey did not finish. (#1615)bytearray(True)is one zero byte, where it was rejected, and boxing a set intoAnyis rejected with advice that compiles. (#1552, #1591)- With
PYSTACHY_DEBUG_LINES=1, a loop's step, awithstatement's file close and a function's shared raise block carry their own source lines. (#1562)
Known limits
Dynamic Any and promoting integers remain experimental opt-ins. The known issues of v0.6.0 remain, except isinstance() of Any values that hold NamedTuple objects: reads of a builtin's name where a module global of that name is unbound (#1512), star imports from a module that binds __all__ inside try or if (#1513), an except clause's as name that an import bound (#1514) and isinstance() tests against a second base class (#1602). The compatibility reference lists the documented deviations.
Platforms
| Native archive | Requirements |
|---|---|
| Linux x86-64 / AArch64 | Ubuntu 24.04 or compatible glibc 2.39+ Linux; LLVM 18 |
| macOS arm64 / x86-64 | macOS 15+, Xcode Command Line Tools; LLVM 20 |
Archives and Docker run without Python; the hosted compiler needs Python 3.11+ and reports commit unknown when installed with pip. Full verification targets Linux x86-64 and ARM64 with CPython 3.13.16. Linux archives are not manylinux packages.
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.6.1 for linux/amd64 and linux/arm64, with LLVM 18 included.
Source commit: 37512410e050da72b97b927f7d69830ed8377faa.
Pystachy v0.6.0
Pystachy v0.6.0 compiles more of the Python found in typed code such as mypy's: classes as values, objects beside numbers and strings in unions, more inferred field types, bytearray and more of the standard library. It also runs unittest suites natively and repairs results that v0.5.0 got wrong. Pystachy remains an experimental compiler for a typed subset of Python.
Classes, unions and generics
type[C]holds the class object ofCor a subclass in variables, fields and containers. Class objects answerisinstance()andissubclass(), construct objects and call class and static methods;type[object]also holds builtin classes such asint. (alpha.2)- A union may hold
int,float,boolorstrbeside objects of the program's classes, and runtime-length tuples hold objects.isinstance(),callable(),Noneand truth tests ofx.anarrow the reads that follow. - A class may have several method-only secondary bases, such as mypyc traits, take type variables from its bases and derive from
Iterator[...].TypeVartakes bounds and constraints, and enum members may come from__new__and run__init__.
Inference and the language
- Fields take their types from more expressions, such as
andandoroperands, comprehensions, module globals and other classes' attributes. Annotations readLiteral[...],TypeGuard,TypeIs,TYPE_CHECKINGimports andNewType. (alpha.1) - An
intargument may reach afloatparameter of a function called directly. Its body computes withintoperations, as CPython's does, under Pystachy's 64-bit integer limits. (#1533) - Sequence patterns match lists, with starred names. Subscripts, slices,
range()and%formatting ask objects for__index__(),%(name)sformats a mapping, and dictkeys()anditems()views act as sets ininand comparisons. bytearraysupports indexing, slicing, slice assignment and its in-place methods; library functions still takebytes. (#1478)
Standard library
- New:
pprint,inspect.Signature,subprocessover fork and exec,importlib.resources,importlib.metadata,sysconfig,platform,base64andgc.concurrent.futuresruns aThreadPoolExecutoron the program's one thread. (library reference) functools.cached_propertyandtotal_ordering,contextlib.ExitStackand modules'__file__are available.decimaladdsexp(),ln(),log10()andDecimalpowers, rounded as libmpdec rounds them, andstrcase methods follow CPython's Unicode rules. (limits)
Testing and performance
- The native pytest runner runs
unittest.TestCaseclasses, layeredconftest.pyfiles, marks,-kand-m, fixture scopes and parameters,tmp_path,capsys,capfdandmonkeypatch. (#1287) strcase methods and character tests read generated Unicode tables, taking 0.3 to 1.9 times CPython's time on Russian, Chinese and French text (measurements). Float powers, rounding,%,//and comparisons of ints with floats run inline.- As opt-ins,
PYSTACHY_JIT_OPT=2runs LLVM's -O2 pipeline in the JIT, andPYSTACHY_PROFILE_GENERATEandPYSTACHY_PROFILE_USEoptimize an executable by its profile. ThePYSTACHY_UNICODE_AUDITsetting is removed.
Correctness repairs
Programs that v0.5.0 compiled now do what CPython does:
==and!=between a value of a union of classes and an object compare the object, by its class's__eq__or by identity, where v0.5.0 could printFalsefor equal objects. (fix)x += ythrough a value typed with a base class calls the in-place method of the object's subclass. Where the results have no common type, the program is rejected. (#1538)- A dict lookup whose key's
__eq__removes and stores its entry again finds it where it moved, where v0.5.0 could write outside the dict. (#1580) - On Linux AArch64, the collector scans the registers saved above
main's frame, where a live object could be freed. (#1553) - Host paths such as
sys.prefixkeep their non-ASCII characters and undecodable bytes, and with dynamicAny, ranges answerisinstance()and==as CPython does. (#1517, #1523, #1595)
Known limits
Dynamic Any and promoting integers remain experimental opt-ins. Known issues include reads of a builtin's name where a module global of that name is unbound (#1512), star imports from a module that binds __all__ inside try or if (#1513), an except clause's as name that an import bound (#1514), isinstance() of Any values that hold NamedTuple objects (#1581) and isinstance() tests against a second base class (#1602). The compatibility reference lists the documented deviations.
Mapping patterns, async, full native mypy and broad concurrency remain outside v0.6.0.
Platforms
| Native archive | Requirements |
|---|---|
| Linux x86-64 / AArch64 | Ubuntu 24.04 or compatible glibc 2.39+ Linux; LLVM 18 |
| macOS arm64 / x86-64 | macOS 15+, Xcode Command Line Tools; LLVM 20 |
Archives and Docker run without Python; the hosted compiler needs Python 3.11+ and reports commit unknown when installed with pip. Full verification targets Linux x86-64 and ARM64 with CPython 3.13.16. Linux archives are not manylinux packages.
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.6.0 for linux/amd64 and linux/arm64, with LLVM 18 included.
Source commit: 817c9cd9e8a638232a65adb916af39735e503282.
Pystachy v0.6.0-rc.2
Pystachy v0.6.0-rc.2 is the last release candidate for v0.6.0. Since rc.1, it keeps the numeric defaults of fields typed as a union with a class under dynamic Any, finds a dict entry that a key's __eq__ moved instead of writing outside the dict, and answers isinstance() and == for ranges held as Any. Pystachy remains an experimental compiler for a typed subset of Python.
Corrections since rc.1
- In a module that opts in to dynamic
Any, a dataclass orNamedTuplefield typed as a union with a class, as iny: int | P = 0, keeps its numeric default when a call leaves it out. Since alpha.2, which began to compile such unions, the field readNone. (#1598) - A dict lookup whose key's
__eq__removes the entry it compares and stores the key again finds the entry where it moved, as CPython does. Previouslyd[k] = vwrote outside the dict there, and reads,in,delandpopanswered wrongly. This predates the alphas. (#1580) - With dynamic
Any,isinstance(x, range)is true for a range, and a range compared with a value of another type is unequal instead of raisingAttributeError. (#1595)
Features carried from the alphas
- Typing and fields: field and annotation types inferred in code like mypy's, sequence patterns on lists, and new standard library modules and functions. Alpha.1
- Classes and unions: more of mypy's class and typing patterns, classes as values, objects beside numbers and strings in unions and runtime-length tuples,
__index__where CPython asks for it, and a widerdecimal. Alpha.2 - Library, types and speed:
pprint,inspect,subprocess,importlib.resources,concurrent.futures,gcandbytearray;intarguments forfloatparameters; nativeunittestsuites; faster string case methods and numeric paths; and a restructured typed IR. Alpha.3 - Release candidate 1: in-place operators that call a subclass's method through a value typed with its base class, enum members whose
__new__annotates its return, and the undecodable bytes of host paths in__file__. rc.1
Known limits
Dynamic Any and promoting integers remain experimental opt-ins. Known issues that predate the alphas include reads of a builtin's name where a module global of that name is unbound (#1512), star imports from a module that binds __all__ inside try or if (#1513), an except clause's as name that an import bound (#1514), isinstance() of Any values that hold NamedTuple objects (#1581) and isinstance() tests against a second base class (#1602). The compatibility reference lists the documented deviations.
Mapping patterns, async, full native mypy and broad concurrency remain outside v0.6.0. Fixes found after this candidate ship in v0.6.0.
Platforms
| Native archive | Requirements |
|---|---|
| Linux x86-64 / AArch64 | Ubuntu 24.04 or compatible glibc 2.39+ Linux; LLVM 18 |
| macOS arm64 / x86-64 | macOS 15+, Xcode Command Line Tools; LLVM 20 |
Archives and Docker run without Python; the hosted compiler needs Python 3.11+ and reports commit unknown when installed with pip. Full verification targets Linux x86-64 and ARM64 with CPython 3.13.16. Linux archives are not manylinux packages. This prerelease keeps the stable defaults at v0.5.0.
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.6.0-rc.2 for linux/amd64 and linux/arm64, with LLVM 18 included.
As a prerelease, this version does not move GitHub's latest release or Docker's latest tag.
Source commit: 299d12ad5b2a4446088a5c0565fa25eb258c5a94.
Pystachy v0.6.0-rc.1
Pystachy v0.6.0-rc.1 freezes the v0.6.0 feature set for final qualification. Since alpha.3, it calls a subclass's in-place operator method through a value typed with its base class, makes enum members whose __new__ annotates its return, and keeps the undecodable bytes of host paths in __file__. Pystachy remains an experimental compiler for a typed subset of Python.
Corrections since alpha.3
x += yand the other in-place operators call the in-place method of the object's class where a subclass defines one and the class thatxis typed with does not, as CPython does, so other names for the object see the change. Previously the class's__add__reboundxto a new object, also in the list and dict displays, conditional expressions andint | Cunions that alpha.2 began to compile. Results with no common type are rejected. (#1538)- An enum class whose
__new__annotates its return, as indef __new__(cls, value) -> "Coord":, makes its members as CPython does. Alpha.2 and alpha.3 raisedRuntimeErroras each member was made. (#1555) - In a directory whose name is not valid UTF-8, the native compiler writes the name's bytes unchanged into
__file__,importlib.metadata's search path and debug locations, as the hosted compiler does. Previouslyos.path.isfile(__file__)was false there. (#1523) - The language and library overviews list
bytearrayand alpha.3's modules as supported, and the documentation's test counts match the current corpus.
Features carried from the alphas
- Typing and fields: field and annotation types inferred in code like mypy's, sequence patterns on lists, and new standard library modules and functions. Alpha.1
- Classes and unions: more of mypy's class and typing patterns, classes as values, objects beside numbers and strings in unions and runtime-length tuples,
__index__where CPython asks for it, and a widerdecimal. Alpha.2 - Library, types and speed:
pprint,inspect,subprocess,importlib.resources,concurrent.futures,gcandbytearray;intarguments forfloatparameters; nativeunittestsuites; faster string case methods and numeric paths; and a restructured typed IR. Alpha.3
Known limits
Dynamic Any and promoting integers remain experimental opt-ins. Known issues that predate the alphas include reads of a builtin's name where a module global of that name is unbound (#1512), star imports from a module that binds __all__ inside try or if (#1513) and an except clause's as name that an import bound (#1514). The compatibility reference lists the documented deviations.
Mapping patterns, async, full native mypy and broad concurrency remain outside v0.6.0. Release candidates accept fixes within the frozen scope.
Platforms
| Native archive | Requirements |
|---|---|
| Linux x86-64 / AArch64 | Ubuntu 24.04 or compatible glibc 2.39+ Linux; LLVM 18 |
| macOS arm64 / x86-64 | macOS 15+, Xcode Command Line Tools; LLVM 20 |
Archives and Docker run without Python; the hosted compiler needs Python 3.11+ and reports commit unknown when installed with pip. Full verification targets Linux x86-64 and ARM64 with CPython 3.13.16. Linux archives are not manylinux packages. This prerelease keeps the stable defaults at v0.5.0.
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.6.0-rc.1 for linux/amd64 and linux/arm64, with LLVM 18 included.
As a prerelease, this version does not move GitHub's latest release or Docker's latest tag.
Source commit: d35417c967f25ac699bb713f4c796dfaf2c57fac.
Pystachy v0.6.0-alpha.3
Pystachy v0.6.0-alpha.3 is the last alpha of v0.6.0. It adds pprint, inspect, subprocess, importlib.resources, concurrent.futures, gc and bytearray, lets an int argument reach a float parameter, runs unittest suites natively, makes string case methods and numeric paths faster, and restructures the typed IR. Pystachy remains an experimental compiler for a typed subset of Python.
Standard library
pprintformats with every option CPython's has, choosing the layout by a value's static type; objects of classes print as theirrepr(). (#1344)inspectgivesParameter,Signatureandcleandoc().subprocessgivesrun(),call(),check_call(),check_output(),getoutput()andPopenover fork and exec.importlibaddsresources,util.resolve_name()andimport_module()of a constant name. (#1417, #1385, #1365, #1474)concurrent.futuresruns aThreadPoolExecutoron the program's one thread:submit()runs the call before it returns.gc.collect()runs the collector, and the module keeps its other settings. (#1416, #1351)functools.total_orderingadds the ordering methods a class lacks, from the ones it defines or inherits, as CPython does. (#1473)- For mypy's own code,
librt.base64andast_serialize, mypy's parser front end, give the results and errors of their C and Rust extensions. (#1434, #1435)
Language and types
bytearrayis a class of the subset: mutable bytes with indexing, slicing, slice assignment and deletion, and the methods that change it in place. (#1478)- An
intorboolargument may reach afloatparameter of a function called directly, which compiles again for it. Its body computes withintoperations, as CPython's does, under Pystachy's integer limits: a result past 64 bits raisesOverflowError, and anintto a negativeintpower raisesValueError. (#1533) %formats a mapping through%(name)sconversions, andinon a dict'skeys()oritems(), and comparisons of two such views, behave as sets. (#1479, #1256)- An optional import's handler runs where an imported module fails at its own import of a missing module, as
ssldoes without_ssl. (#1424) - Fields take their types from sets of one type and from other classes' attributes,
tuple()takes sets and dicts, tab indentation follows CPython's tokenizer, and a dynamic-Anydisplay may read a name that an earlier item's:=binds. (#1388, #1405, #1343)
Testing
The native pytest runner runs unittest.TestCase classes, test packages with layered conftest.py files, marks, -k and -m, fixture scopes and parameters, tmp_path, capsys, capfd and monkeypatch. It reports a test it cannot compile and leaves it out. (#1287)
Performance
str's case methods and character tests read generated Unicode tables directly, taking 0.3 to 1.9 times CPython's time on Russian, Chinese and French text (measurements); thePYSTACHY_UNICODE_AUDITsetting is removed. (#1518)- Float powers, rounding,
%and//, comparisons of ints with floats,bytes(list)and masked 32-bit integer arithmetic run inline, and larger objects take a free slot without a call. (#1436, #1449, #1437, #1441, #1447, #1445) - A range loop that indexes a list at a loop-invariant offset runs one checked test and then an unchecked loop that the Lean checker proves. (#1450, #1455)
- As opt-ins,
PYSTACHY_JIT_OPT=2runs LLVM's -O2 pipeline in the JIT, andPYSTACHY_PROFILE_GENERATEandPYSTACHY_PROFILE_USEbuild an executable with a profile of its own runs. (#1456, #1444)
Compiler internals
The typed IR defines each operation in one table, closes its operand spellings, prints and parses as text, and has its shape proved in Lean. Frontend records leave the IR module, and layout reads lower to machine operations before LLVM. None of this changes a compiled program. (#1541 to #1545, #1284, #1285)
Correctness repairs
On Linux AArch64, the collector also scans the registers that main or an extension's entry saves above its frame record, where LLVM could keep a pointer across an allocation that the collector then freed. (#1553)
Known limits and platforms
Dynamic Any and promoting integers remain experimental opt-ins. Mapping patterns, async, full native mypy and broad concurrency are outside this alpha. x += y on a value typed as a class calls that class's __add__ even where the object's subclass defines __iadd__ (#1538). The compatibility reference lists the documented deviations.
| Native archive | Requirements |
|---|---|
| Linux x86-64 / AArch64 | Ubuntu 24.04 or compatible glibc 2.39+ Linux; LLVM 18 |
| macOS arm64 / x86-64 | macOS 15+, Xcode Command Line Tools; LLVM 20 |
Archives and Docker run without Python; the hosted compiler needs Python 3.11+ and reports commit unknown when installed with pip. Full verification targets Linux x86-64 and ARM64 with CPython 3.13.16. Linux archives are not manylinux packages. Prereleases leave the stable latest unchanged.
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.6.0-alpha.3 for linux/amd64 and linux/arm64, with LLVM 18 included.
As a prerelease, this version does not move GitHub's latest release or Docker's latest tag.
Source commit: 8259611ec88d5aa6af82d0098afb9dd621eb5617.
Pystachy v0.6.0-alpha.2
Pystachy v0.6.0-alpha.2 continues the v0.6.0 series. It compiles more of the class and typing patterns in mypy's own code, uses classes as values, holds objects beside numbers and strings in unions and in runtime-length tuples, asks objects for __index__ where CPython does, and extends decimal. Pystachy remains an experimental compiler for a typed subset of Python.
Classes and generics
- A class may name several method-only secondary bases: mypyc traits, generic bases, and bases that declare attributes by annotation, define
@propertygetters or extend each other. An override may return a class derived from the one the base's method returns. (#1335, #1350, #1373, #1457, #1463) - A class is generic in the type variables its bases pass on and may derive from
Iterator[...]orIterable[...].TypeVartakes bounds and constraints that are types, and objects of two sibling classes take their nearest common base. (#1352, #1391, #1346, #1243) typing.final,mypy_extensions.traitandmypyc_attr(...)may decorate classes, and an alias ofFlexibleAlias[T, X]stands forX, as in mypy. (#1275, #1342)- Enum members run the class's
__init__; a__new__in the documented form makes the members, and_simple_enumandglobal_enumwork. (#1321, #1348)
Classes as values
type[C] holds the class object of C or of a subclass in variables, fields, defaults and containers. Class objects answer isinstance() and issubclass(), construct objects, and read the class attributes and call the class and static methods of the class they are. type[object], or type, holds any class's class object, including builtin classes such as int, and type(x) gives one; calling a type[object] value stays rejected. (#1315, #1361, #1372, #1406, #1407)
Unions, tuples and sets
- A union may hold
int,float,boolorstrbeside objects of the program's classes, dispatching operators and comparisons on the member it holds, andsum()adds objects in CPython's order. A union may also hold aCallablebeside scalars and containers. (#1369, #1448) isinstance(),callable(),Noneand truth tests ofx.anarrow the reads that follow until the attribute may change. (#1453)- Runtime-length tuples hold objects of a class or of a union of classes, and tuples of other lengths join into them. (#1292, #1294, #1297)
AbstractSet[T]holds sets and frozensets. Frozensets hash as in CPython and serve as dict keys and set elements. (#1413, #1380)
Fields, globals and defaults
- Fields take their types from module constants, annotated module globals and their items, and globals whose bindings agree on a type. (#1295, #1368, #1375)
- A parameter whose default is an
object()sentinel keeps its annotated type, and a read-onlySequence[T] = ()default compiles as an empty list.if NAME:directly afterNAME = TrueorNAME = Falseis decided when compiling. (#1362, #1390, #1338) - Type alias values and evaluated annotations raise CPython's
AttributeErrorwhen they read a module attribute that a circular import has not bound yet. (#1399, #1400)
The index protocol
Subscripts, slices, range() and the integer parameters of list, tuple and str methods ask objects for __index__() and take an Any index, in CPython's order. In % formatting, %x, %o and %c ask for __index__(), and %d asks for __int__() first. (#1367, #1396, #1425)
Standard library and repairs
decimaladdssum()ofDecimalvalues,exp(),ln(),log10()and powers with aDecimalexponent, correctly rounded as libmpdec computes them, and the remainingnext_*,compare_*and*_magoperations. (#1370)strmethods map and test the case of non-ASCII text by CPython's per-character rules;bytesmethods stay ASCII-only. (#1518)librt.internal, mypy's cache codec, matches the C extension byte for byte. (#1276)format()of acomplexraisesValueErrorfor a width or precision pastsys.maxsize, as CPython does. (#1521)math.prod()with astror list start raises CPython'sTypeErrorfor aNoneitem of a union of classes, where it crashed.
Known limits and platforms
Dynamic Any and promoting integers remain experimental opt-ins. Mapping patterns, async, full native mypy and broad concurrency are outside this alpha. The compatibility reference lists the documented deviations.
| Native archive | Requirements |
|---|---|
| Linux x86-64 / AArch64 | Ubuntu 24.04 or compatible glibc 2.39+ Linux; LLVM 18 |
| macOS arm64 / x86-64 | macOS 15+, Xcode Command Line Tools; LLVM 20 |
Archives and Docker run without Python; the hosted compiler needs Python 3.11+ and reports commit unknown when installed with pip. Full verification targets Linux x86-64 and ARM64 with CPython 3.13.16. Linux archives are not manylinux packages. Prereleases leave the stable latest unchanged.
Release assets
Native compiler archives for Linux x86-64/AArch64 and macOS arm64/x86-64 are attached below, with their SHA-256 checksums in SHA256SUMS. They require LLVM 18 on Linux or LLVM 20 on macOS; see the installation instructions.
Docker image: dta67/pystachy:v0.6.0-alpha.2 for linux/amd64 and linux/arm64, with LLVM 18 included.
As a prerelease, this version does not move GitHub's latest release or Docker's latest tag.
Source commit: e2b97bb452ac2042a346e915eb9017f6e8f97328.