
Antoine Pitrou wrote:
On Fri, 16 Apr 2021 18:08:58 -0000 "Denis Kotov" redradist@gmail.com wrote:
Okay lets try to discuss one by one:
Readability - less code, most code is hidden by abstraction without losing performance
In CPython code lots of stuff like Py_INCREF, Py_DECREF .. it could be fixed with C++ std::shared_ptr<> (RustPython use analog Arc<>) std::shared_ptr<> would be a bad replacement for CPython's reference
counting for two reasons:
- the reference count is maintained in a separate memory block (unless
you were careful enough to use std::make_shared() for allocation) 2) the reference count is atomic, and this has been proven to slow down CPython by 10-20%.
Rust have 2 ref count classes Rc and Arc. First is without atomic, single threaded, second is with atomic and could be used in multiple thread. It is possible to implement the same std::ref_ptr like Rc without atomic variables