Skip to content
/ monty Public
  • Sponsor
  • Notifications You must be signed in to change notification settings
  • Fork 5

A language toolchain for explicitly typed annotated Python. 🐍

License

Notifications You must be signed in to change notification settings

mental32/monty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

25791ae Β· Oct 2, 2023
Jun 11, 2023
Oct 2, 2023
Jun 11, 2023
Jun 11, 2023
Feb 20, 2022
Oct 2, 2023
Oct 2, 2023
Jun 11, 2023
Oct 2, 2023
Oct 2, 2023
Jun 11, 2023
Oct 2, 2023
Oct 2, 2023
Oct 2, 2023
Oct 2, 2023
Mar 22, 2022
Sep 17, 2023
Oct 2, 2023
Sep 17, 2023
Jul 13, 2021
Oct 2, 2023
Feb 1, 2022

Repository files navigation

Monty

A language toolchain for explicitly typed annotated Python.

Index

Abstract

Monty (/ˈmΙ’ntΙͺ/) is a language toolchain for a subset of Python 3.0+ it is designed from the ground up to be an LSP-first compiler, emphasizing high responsiveness and extraordinarily fast compile times.

Similar alternatives are already mature and pretty impressive, namely:

The compiler aims to maintain the inherent dynamism of Python while incorporating advanced type inference and type-checking capabilities.

Key Differentiators:

  1. Compile-Time Execution of Global Scope: Monty evaluates code in the global scope at compile-time, thereby making the import process static. This architectural decision is intended to encourage the segregation of business logic from initialization code.

  2. Advanced Typing Semantics: Monty's type system is influenced by prominent type checkers such as pytype, pyright, and pyre. It employs advanced type inference algorithms and supports a variety of type-narrowing techniques.

Monty is not intended to ever be a production grade language, it is a project I enjoy working on in my spare time and most recently I have decided to transition away from total coverage of Python and pick out a, strict, toy, subset of the language.

Building the compiler

You will need a fairly recent version of rustc, I am building locally with 1.72.0

Then specify that you would like to build the montyc binary, dropping the --release flag as needed.

cargo build --release --bin montyc

Crate/Repository Layout

  • /montyc is the compiler binary, it is a thin wrapper around montyc_driver
  • /montyc_driver is where all the magic happens, type checking/inference, calls into codegen, etc...
  • /montyc_codegen is where codegen providers are, currently only Cranelift is supported but I'd like to support both LLVM and GCC in the future.
  • /montyc_hlirt is a High Level Interpreter Runtime (HLIRT) and is a minimal but geniune Python interpreter used mainly for compile time evaluation.
  • /montyc_query is where the query interface is defined for the driver.
  • /montyc_flatcode is where AST -> FlatCode lowering happens.
  • /montyc_parser is the parser implementation.
  • /montyc_core is where all fundamental types used in this project go to live.

Related projects

Releases

No releases published

Sponsor this project

Sponsor

Packages

No packages published

Contributors 3

Languages