List / set / dict comprehensions
Monty inlines list, set, and dict comprehensions into the surrounding code object. The user-visible behaviour follows PEP 709: inlined comprehensions, no synthetic frame in tracebacks, comprehension targets do not leak into the enclosing scope.
locals()while a comprehension is running. CPython exposes the comprehension’s active targets inlocals()during the comprehension body. Monty does not implementlocals()introspection.- Generator expressions.
(x for x in iterable)parses but currently materialises to alistrather than a lazy iterator. - Maximum number of
forclauses. Monty caps a single comprehension at 255forclauses; exceeding this raisesSyntaxError: comprehension has too many nested clauses (N); maximum is 255. Per-clause operand-stack growth means real comprehensions hit a tighterSyntaxError: comprehension target + iterator count exceeds u8 depth operandwell before that point. CPython has no equivalent compile-time limit. The cap bounds compiler recursion depth on attacker-controlled source.