monty 0.0.21

A sandboxed, snapshotable Python interpreter written in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
# Self-referential list: a contains itself
# This creates a cycle where a's refcount is 2 (variable + self-reference)
# Without cycle detection, when 'a' goes out of scope, refcount drops to 1
# but the object is never freed (memory leak)
#
# NOTE: We return len(a) instead of a because repr(a) would cause infinite
# recursion / stack overflow (a separate bug - Python handles this by printing [...]
# for cyclic references)
a = []
a.append(a)
len(a)
# ref-counts={'a': 2}