Skip to content

Limitations

Monty is a sandbox, not a Python implementation aiming for completeness. It implements enough Python for a model to express what it wants to do, and deliberately stops there. Everything it does implement is meant to behave exactly like CPython 3.14; everywhere it does not, the divergence is written down.

This page gives you the shape of the subset. The other pages in this section are the exhaustive record, one per builtin, module or construct. They list every known divergence, including the ones that feel obvious, so a behaviour missing from them can be assumed to match CPython 3.14. They exist for development and for agents debugging code that runs on Monty; most users need only this page. For compilation and runtime limits, see resource limits.

Language features

Supported:

  • def, async def, nested functions, closures, lambda
  • Decorators on functions and classes
  • Simple classes: instance methods, __init__, __repr__/__str__, __eq__/__hash__, __iter__/__next__, __contains__, __index__, __int__/__float__, __abs__, __round__, __floor__/__ceil__/__trunc__, __call__, __getitem__/__setitem__, unary +/-/~, binary arithmetic and reflected operators, class variables
  • @dataclass, with the eq= and frozen= options only (every other option raises NotImplementedError), field() (with default=... / default_factory=...) and __post_init__, but no fields() or asdict(), plus host class instances passed in and out (and host classes the sandbox may instantiate when granted)
  • List, dict and set comprehensions
  • try / except / else / finally, raise ... from ...
  • for, while, if / elif / else, break, continue, pass, assert, global, nonlocal, return
  • with statements, for files and for classes implementing __enter__ / __exit__
  • Binary write/update files (open(path, 'w+b')); other update modes remain unsupported. See open.md for file buffering and method limitations.
  • match statements with every PEP 634 pattern kind and guards, see match.md
  • f-strings (including the = debug form), str.format() and format(), with !r / !s / !a conversions, format specs and nested replacement fields
  • async / await, and asyncio.run / asyncio.gather / asyncio.create_task / asyncio.wait / asyncio.sleep
  • import x, import x.y, from x import y, z as w, from x import * (see modules.md); a module the sandbox does not have is requested from the host, see modules.md, which may answer with the module’s .py file from the working directory instead, see modules from files
  • Starred unpacking everywhere CPython allows it
  • Runtime generic aliases (list[int]) and | unions (int | None), see typing.md

Rejected at parse time, with NotImplementedError before any code runs:

  • Metaclasses (class Foo(metaclass=M):)
  • Decorators on methods — so no @classmethod, @staticmethod, @property
  • yield / yield from — there are no generator functions. Generator expressions parse, but currently materialise to a list
  • del, both del x and del d[k]
  • try* / except* exception groups
  • PEP 695 type aliases
  • async with, async for and async comprehensions
  • t-strings

Missing in other ways:

  • User-defined exception classes, and subclasses of other native types. Classes inherit only from classes defined in Python and object, so the built-in exception types are a fixed set.
  • Function attributes. fn.__name__, fn.__doc__ and friends raise AttributeError, and new attributes cannot be set — so functools.wraps-style metadata copying and registries keyed on fn.__name__ have no equivalent.
  • compile, globals and __import__ — all raise NameError. eval and exec exist (source text only), and so does locals(); see eval_exec.md.
  • Third-party packages. There is no sys.path and no site-packages.

Standard library

The following modules are present:

ModuleDivergences
annotationlibannotationlib.md
asyncioasyncio.md
base64base64.md
binasciibase64.md
bisectbisect.md
collectionscollections.md
colorsysmodules.md
copycopy.md
csvcsv.md
dataclassesdataclasses.md
datetimedatetime.md
decimaldecimal.md
fnmatchfnmatch.md
functoolsfunctools.md
hashlibhashlib.md
itertoolsitertools.md
jsonjson.md
keywordmodules.md
mathmath.md
osos.md
os.pathos.md
pathlibpathlib.md
posixpathos.md
randomrandom.md
rere.md
statmodules.md
statisticsstatistics.md
syssys.md
timetime.md
tomllibtomllib.md
typingtyping.md
unicodedataunicodedata.md

Each covers only part of its CPython surface — often a small part. colorsys, keyword and stat run CPython’s own source. itertools, hashlib, tomllib and fnmatch are the other exceptions: itertools implements every name it exports, hashlib every guaranteed algorithm, and tomllib and fnmatch their whole three- and four-name surfaces. The absent names are missing from the module namespace rather than stubbed, so they fail type checking as well as raising AttributeError at runtime.

Notably absent: enum, contextlib, io, string, struct, operator, inspect, logging, traceback, uuid, urllib. Some of those are absent by design — socket, subprocess, multiprocessing, threading and ctypes would breach the sandbox — and others are simply not implemented yet.

The authoritative list is modules.md.

Things that work but not quite like CPython

A few divergences are worth knowing up front because they change how code behaves rather than whether it runs. Each links to the page that owns it, which is where the full account lives:

  • assert failures get pytest-style messages. assert 2 == 5 raises AssertionError: assert 2 == 5, not CPython’s empty AssertionError. Turn it off with assert_message_annotations=False on checkout() (assert.md).
  • enumerate, zip and reversed are eager, not lazy. So enumerate(itertools.count()) runs until a resource limit trips (builtins.md). map and filter are lazy, but synchronous consumers such as list() cannot suspend in their callbacks (iter.md).
  • re is backed by Rust’s fancy-regex, not CPython’s engine: no bytes patterns, no re.VERBOSE constant, and some error messages differ (re.md).
  • Only the class dunders listed above are dispatched. __lt__ and __len__ raise TypeError as if undefined, while in-place arithmetic dunders are skipped in favor of binary arithmetic (@= is rejected at compile time). __bool__ and the __getattr__ family are ignored silently, so an instance is always truthy (classes.md).
  • There is no event loop inside the sandbox. async / await work, and asyncio exposes run, gather, create_task, wait, sleep, Task, InvalidStateError and the three wait constants; everything else does not exist (asyncio.md).
  • Only UTF-8, ASCII, UTF-16 and UTF-32 codecs exist. latin-1 and friends raise LookupError (encoding.md).

How to go deeper

For a specific feature, open the page in this section named after the builtin, module or construct. The pages are the limitations/ directory of the repository, published verbatim. If you hit something that is neither in the subset nor on these pages, open an issue.