Supported Features
Monty can run a reasonable subset of Python code - enough for your agent to express what it wants to do.Core Language Features
Functions
Functions
Monty supports standard Python function definitions including:
- Function definitions with
def - Async functions with
async def - Positional and keyword arguments
- Default parameter values
- Return statements
- Nested functions
Control Flow
Control Flow
Full support for Python control flow statements:
if,elif,elseconditionalswhileloopsforloops with iteratorsbreakandcontinuestatementsreturnstatements
Data Types
Data Types
Monty supports common Python built-in types:
- Primitives:
int,float,bool,None - Strings:
strwith full Unicode support - Collections:
list,tuple,dict,set - Functions: Function objects and lambdas
Async/Await
Async/Await
First-class support for asynchronous programming:
async deffunction definitionsawaitexpressions- Coroutines and async generators
- Integration with host event loop
Type Hints
Type Hints
Full support for modern Python type hints:
- Function parameter and return type annotations
- Variable type annotations
- Generic types from
typingmodule - Built-in type checking with ty
Operators
Operators
Standard Python operators are supported:
- Arithmetic:
+,-,*,/,//,%,** - Comparison:
==,!=,<,>,<=,>= - Logical:
and,or,not - Membership:
in,not in - Identity:
is,is not
Comprehensions
Comprehensions
All Python comprehension types:
- List comprehensions
- Dict comprehensions
- Set comprehensions
- Generator expressions
Exception Handling
Exception Handling
Full exception handling support:
try/except/finallyblocksraisestatements- Built-in exception types
- Custom exception messages
String Formatting
String Formatting
Multiple string formatting options:
- f-strings with expressions
.format()method%formatting- String concatenation
Built-in Functions
Monty provides access to essential Python built-in functions:- Type conversions:
int(),str(),float(),bool(),list(),dict(),set(),tuple() - Iteration:
len(),range(),enumerate(),zip(),iter(),next() - Functional:
map(),filter(),sorted(),sum(),min(),max(),any(),all() - I/O:
print()(output captured by host) - Inspection:
type(),isinstance(),hasattr(),getattr(),setattr() - Other:
abs(),round(),repr(),id()
Monty’s
print() function captures output and returns it to the host via callbacks, rather than writing directly to stdout.Performance Characteristics
Monty provides excellent performance for agent workloads:- Startup time: <1μs from code to execution result
- Runtime performance: Generally between 5x faster and 5x slower than CPython
- Memory efficiency: Manual reference counting and controlled allocation
- Resource limits: Built-in tracking of memory, allocations, and execution time
Next Steps
Standard Library
Explore supported stdlib modules like
sys, os, typing, and asyncioLimitations
Understand what Python features are not supported
