Add freelists for PyComplex, PyInt, PyRange by youknowone · Pull Request #7345 · RustPython/RustPython
youknowone added a commit to youknowone/RustPython that referenced this pull request
* Add freelists for PyComplex, PyInt, PyBoundMethod, PyRange - PyComplex(100), PyInt(100), PyBoundMethod(20), PyRange(6) - Use try_with instead of with in all freelist push/pop to prevent panic on thread-local access during thread teardown * Use alloc::dealloc in FreeList::Drop to avoid thread-local access panic During thread teardown, Box::from_raw triggers cascading destructors that may access already-destroyed thread-local storage (GC state, other freelists). Use raw dealloc instead to free memory without running destructors. * Auto-format: cargo fmt --all * Fix clippy: use core::alloc::Layout instead of alloc::alloc::Layout * Address review: PyBoundMethod clear=false, update FreeList doc comment - Set clear=false on PyBoundMethod (tp_clear=NULL in classobject.c) - Update FreeList doc comment to match actual Drop behavior (raw dealloc) * Remove PyBoundMethod freelist to fix refcount/weakref test failures Non-Option PyObjectRef fields retain references in freelist, causing weakref and refcount assertions to fail in test_unittest, test_multiprocessing, and test_socket. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>