[Python-Dev] Re: How about using modern C++ in development of CPython ?

2021年4月16日 11:55:19 -0700

On 2021年4月16日 18:08:58 -0000
"Denis Kotov" <[email protected]> wrote:
> 
> Okay lets try to discuss one by one:
> 1) 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:
1) 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%.
That does not mean that CPython couldn't benefit from C++-based
abstractions, but they would have to be implemented (or taken from
another project such as pybind11).
Regards
Antoine.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/YEXWX6NT5W533PFIJVXAKHQWJCY43BDZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to