Latest Results
Add `functools.partial`
A new `HeapData` variant dispatched from `call_heap_callable`, which lifts the
bound arguments out of the heap, releases the borrow, and re-enters
`call_function`. Doing it that way means the wrapped callable may be another
partial, an external function, or the same partial again.
Nested partials are flattened at construction and call-time keywords replace
bound ones in place, both as CPython does. Bound keywords are a
`Vec<(Value, Value)>` rather than a `Dict` because merging has to preserve the
bound order while replacing values positionally, and there are rarely more than
a couple of names to scan.
`partial` is a descriptor, as it is in CPython 3.14, so one stored as a class
attribute binds the instance after the arguments it already carries.
That also means a `Partial` and a `BoundMethod` can nest without limit, and
since the re-dispatch grows the native Rust stack rather than pushing a VM
frame, a deep chain aborted the process. Each dispatch charges the native
re-entry budget `evaluate_function` already uses for `map()` and the other
synchronous callbacks, so the chain raises `RecursionError` instead. The
1000-frame Python recursion limit is not low enough to help: at roughly 8.6 KiB
of stack per link, an 8 MiB stack is gone by depth 950.
The `heap/mod.rs` arms are the part to review: omitting the type from
`py_dec_ref_ids` leaks its arguments, omitting it from `for_each_child_id`
frees a live object. `refcount__functools_partial.py` covers both.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BpcVDuXTYe8JqGkfYDqJqMrewitt94:functools-partial Latest Branches
0%
0%
trungminhdo4-glitch:fix/720-json-leak 0%
© 2026 CodSpeed Technology