v0.0.18
pydantic/montyv0.0.18May 29, 2026by samuelcolvin
AI Summary
Major release featuring significant garbage collection improvements including trial deletion GC for cycle collection, implementation of context manager support, and the open builtin function with limitations. Also includes numerous bug fixes and performance optimizations.
Key Highlights
- Implemented 'trial deletion' GC to collect cycles
- Added context manager support (with statement)
- Implemented open() builtin with buffered methods
- Added dart/flutter bindings
- Fixed exception stack corruption in various raise cases
New Features
- Trial deletion GC for cycle collection
- Context manager support
- open() builtin implementation
- Dart/flutter bindings
- Hash caching optimizations
- gc.collect() function with test-hooks feature
Full Release Notes
## What's Changed * switch `pre-commit` -> `prek` by @samuelcolvin in https://github.com/pydantic/monty/pull/392 * gc: properly release references held by values in cycles by @davidhewitt in https://github.com/pydantic/monty/pull/399 * bump to Rust 1.95 by @davidhewitt in https://github.com/pydantic/monty/pull/401 * fix GC tracking for `datetime.tzinfo` by @rsr5 in https://github.com/pydantic/monty/pull/397 * clean up some dict view implementations by @davidhewitt in https://github.com/pydantic/monty/pull/402 * convert `py_repr` methods to take `&mut VM` by @davidhewitt in https://github.com/pydantic/monty/pull/403 * make `Task` have owning references to its coroutine / gather by @davidhewitt in https://github.com/pydantic/monty/pull/404 * fix hash equality for trivial types by @davidhewitt in https://github.com/pydantic/monty/pull/405 * further isolate unsafe code within `Heap` implementation by @davidhewitt in https://github.com/pydantic/monty/pull/406 * fix: parse errors must not leak ruff AST Debug formatting by @smigolsmigol in https://github.com/pydantic/monty/pull/390 * ci: fix lint failures from nightly clippy by @davidhewitt in https://github.com/pydantic/monty/pull/415 * Add `gc.collect()` function only with `test-hooks` feature by @davidhewitt in https://github.com/pydantic/monty/pull/398 * merge lifetimes in `VM` to a single lifetime by @davidhewitt in https://github.com/pydantic/monty/pull/416 * fix lifetimes from conflicting merges to `main` by @davidhewitt in https://github.com/pydantic/monty/pull/417 * fix `no active frame` panic on duplicate coroutine in `gather` by @rsr5 in https://github.com/pydantic/monty/pull/410 * cache the hash value of interned / static strings by @davidhewitt in https://github.com/pydantic/monty/pull/418 * fix: avoid panic when list.sort() key callback mutates the list by @SAY-5 in https://github.com/pydantic/monty/pull/413 * implement "trial deletion" GC to collect cycles by @davidhewitt in https://github.com/pydantic/monty/pull/407 * reject reusing an already-awaited external future via `gather` by @rsr5 in https://github.com/pydantic/monty/pull/420 * Add dart/flutter bindings by @runyaga in https://github.com/pydantic/monty/pull/414 * inline hash caching directly into relevant types by @davidhewitt in https://github.com/pydantic/monty/pull/422 * Fix async external function exception propagation by @vivekraghuram in https://github.com/pydantic/monty/pull/424 * note that `make install-py` is often necessary in CLAUDE.md by @davidhewitt in https://github.com/pydantic/monty/pull/426 * fix typo in CLAUDE.md by @davidhewitt in https://github.com/pydantic/monty/pull/427 * fix exception stack corruption in various `raise` cases by @davidhewitt in https://github.com/pydantic/monty/pull/428 * avoid unbounded recursion in two tuple traversal cases by @davidhewitt in https://github.com/pydantic/monty/pull/429 * move all `String` heap allocation to go through `allocate_string` helper by @davidhewitt in https://github.com/pydantic/monty/pull/430 * Bound AST depth produced by folding flat elif and bool-op chains by @dsp-ant in https://github.com/pydantic/monty/pull/437 * Pre-check requested size in bytes(int) constructor against resource l… by @dsp-ant in https://github.com/pydantic/monty/pull/435 * Clean up compiler - no longer emit dead code, simpler exception handlers, ensure jumps hit the same depth by @davidhewitt in https://github.com/pydantic/monty/pull/432 * agents: note that certain heap operations only need `&Heap` by @davidhewitt in https://github.com/pydantic/monty/pull/441 * refactor `GatherFuture` to be a state machine by @davidhewitt in https://github.com/pydantic/monty/pull/433 * fix panic on duplicate parameter names by @smigolsmigol in https://github.com/pydantic/monty/pull/382 * only swallow `AttributeError` in `getattr` by @davidhewitt in https://github.com/pydantic/monty/pull/442 * deduplicate source lines in tracebacks by @davidhewitt in https://github.com/pydantic/monty/pull/443 * fix more panics by @davidhewitt in https://github.com/pydantic/monty/pull/372 * fix further panics in integer operations by @davidhewitt in https://github.com/pydantic/monty/pull/444 * optimize operand load on bytecode loop by @davidhewitt in https://github.com/pydantic/monty/pull/446 * simplify jump calculation by @davidhewitt in https://github.com/pydantic/monty/pull/445 * refactor futures to have state machines like gather by @davidhewitt in https://github.com/pydantic/monty/pull/447 * Bound except-clause tuple matching by the recursion-depth limit by @dsp-ant in https://github.com/pydantic/monty/pull/439 * Bound container pre-allocation driven by iterator size hints by @dsp-ant in https://github.com/pydantic/monty/pull/434 * optimize cycle collector to have per-node work stack, not per-edge by @davidhewitt in https://github.com/pydantic/monty/pull/450 * move limits in the compiler to return syntax errors rather than panic by @davidhewitt in https://github.com/pydantic/monty/pull/449 * enforce JSON integers do not exceed Monty's BigInt limits by @davidhewitt in https://github.com/pydantic/monty/pull/431 * avoid unbounded recursion in `monty_to_py` by @davidhewitt in https://github.com/pydantic/monty/pull/453 * avoid UB in `Heap::dec_ref` by @davidhewitt in https://github.com/pydantic/monty/pull/451 * Implement `open` builtin, with limitations by @samuelcolvin in https://github.com/pydantic/monty/pull/456 * add more limitations by @samuelcolvin in https://github.com/pydantic/monty/pull/460 * clean up unsupported results in `evaluate_function` by @davidhewitt in https://github.com/pydantic/monty/pull/463 * avoid panic on string id 128..255 by @davidhewitt in https://github.com/pydantic/monty/pull/466 * collect cell vars from `for` / `while` / `if` control flow expressions by @davidhewitt in https://github.com/pydantic/monty/pull/465 * Context manager support by @samuelcolvin in https://github.com/pydantic/monty/pull/462 * Implement buffered `open()` methods by @samuelcolvin in https://github.com/pydantic/monty/pull/461 * move `value_to_i32` by @samuelcolvin in https://github.com/pydantic/monty/pull/468 * fix(repl): Add local/global store operation in comprehension expressions by @Embers-of-the-Fire in https://github.com/pydantic/monty/pull/297 * Ruff depth limit by @samuelcolvin in https://github.com/pydantic/monty/pull/391 * fix: name-based identity and equality for external function values by @mbeschastn0v in https://github.com/pydantic/monty/pull/458 * Cap comprehension generator count to prevent compiler stack overflow by @samuelcolvin in https://github.com/pydantic/monty/pull/470 * fix overlay append quota by @samuelcolvin in https://github.com/pydantic/monty/pull/472 * Fstring precision limits by @samuelcolvin in https://github.com/pydantic/monty/pull/474 * fix(file): do not serialize OpenFile buffer_meta cache across snapshots by @samuelcolvin in https://github.com/pydantic/monty/pull/471 * proc macro for function signature parsing by @samuelcolvin in https://github.com/pydantic/monty/pull/467 * apply `INT_MAX_STR_DIGITS` guard to natural JSON BigInt path by @samuelcolvin in https://github.com/pydantic/monty/pull/475 * prep v0.0.18 release by @samuelcolvin in https://github.com/pydantic/monty/pull/476 ## New Contributors * @smigolsmigol made their first contribution in https://github.com/pydantic/monty/pull/390 * @SAY-5 made their first contribution in https://github.com/pydantic/monty/pull/413 * @vivekraghuram made their first contribution in https://github.com/pydantic/monty/pull/424 * @dsp-ant made their first contribution in https://github.com/pydantic/monty/pull/437 * @mbeschastn0v made their first contribution in https://github.com/pydantic/monty/pull/458 **Full Changelog**: https://github.com/pydantic/monty/compare/v0.0.17...v0.0.18