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

2021-04-16 Thread Denis Kotov
edwin@211mainstreet.net wrote:
> Anyone who has done a language change on a project knows that it is a huge 
> disruption.  You need solid justification to make such a change.  All I have 
> seen in this thread is personal opinion.  Since this is a personal opinion 
> exchange, I am of the humble opinion that the personal opinions of core devs 
> matter the most, since a language change would affect them more than anyone 
> else.
> April 16, 2021 1:47 PM, redrad...@gmail.com wrote:
> > Guys, the issue is that I most of the time see that somebody used C++ for 
> > one or two times, did not
> > understand it and left with bad taste ...
> > Please, answer me question, if you will go in gym two times, will you get 
> > stop training and say
> > that it does not fit in your life ?
> > ___
> > Python-Dev mailing list -- python-dev@python.org
> > To unsubscribe send an email to python-dev-le...@python.org
> > https://mail.python.org/mailman3/lists/python-dev.python.org
> > Message archived at
> > https://mail.python.org/archives/list/python-dev@python.org/message/LWJ4WGWK...
> > Code of Conduct: http://python.org/psf/codeofconduct
> >

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<>)

2) Maintainability - no code duplication in favor of using reusable classes
In CPython I saw custom lists and stacks and so on ... with C++ it could be 
switched to std::list<>, std::stack<> and so on
In CPython lots of custom implemented algorithms that could be changed by using 
C++  that support lots of types !!

3) RAII - Resource Acquisition Is Initialization, predictable allocation and 
free resources
Also reusable peaces of code will help of maintaining life-time of objects with 
RAII, not only at the end of function, but in general, because life-time 
resource will be bound to object life-time
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/HCZBCLFRQGPKRGJ5JAVIMOWBBLMSNOVG/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2021-04-16 Thread Denis Kotov
Ethan Furman wrote:
> On 4/16/21 10:43 AM, redrad...@gmail.com wrote:
> > Take a look at this video https://www.youtube.com/watch?v=D7Sd8A6_fYU
> > or read some articles ... otherwise I will need to spend too many time 
> > providing evidences to you and after all you will probably will reject 
> > anyway (because lots of people is biased and they even do not understand 
> > that, it is not about you, it is in general)
> > You are the one proposing the change, so it's up to you to provide the 
> > evidence for it.  If you aren't willing to put in 
> a few hours for that effort, why should we put the weeks and months to port 
> the code over?
> --
> ~Ethan~

I do not ask porting code, I ask using new code with C++ and if code was tested 
enough to reimplement it in C++ with RAII, 

Also I suggest using C++ excepting that most of the people here now it ... It 
was not intended to teach C++ here, especially in Mail List )))

And reason why you at least should try learn other languages, it is because it 
will make you better developer
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/7MLCM7DKBAPMBBIRWZHHTOGL76GPIYWM/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2021-04-16 Thread Denis Kotov
Antoine Pitrou wrote:
> On Fri, 16 Apr 2021 18:08:58 -
> "Denis Kotov" redrad...@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:
> 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%.

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
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/BOYTNQSCUXBWHUXZFE7RZSBWQQZZRZ5M/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2021-04-16 Thread Denis Kotov
Christian Heimes wrote:
> On 16/04/2021 19.14, redrad...@gmail.com wrote:
> > My personal stop of contributing in CPython is that it is written in pure C 
> > !!
> > I wrote code in both: pure C and C++, but I like writing code in C++, 
> > because it simplifies things without losing perfomance
> > There are plenty of Open Source projects that could use more capable C++
> developers. :)
> I'm not a fan of C++. It has its use cases, e.g. in UI. Python core
> isn't the best fit. AFAIK most core devs are not fluent in C++. Despite
> it's name, C++ is really a different language than C. It has a different
> ABI and stdlib than C, too. In my personal opinion C++ won't give us any
> net benefits. I'd much rather go for Rust than C++ to gain memory safety.
> Christian


Rust is not syntax compatible with C and that is why I suggest to use C++.
If you are not fan of C++, with Rust there are also templates and sometimes 
even harder errors for life-time than C++ error template instantiation )))

Rust does not fit in 30 years code base written in C like C++ does
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/NO7EE4CQ5ALKEHTTNCDZ3B36QA7HQXGP/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2022-01-16 Thread Denis Kotov
Yes, each compiler implement its own compiler ABI, but for me it is not a 
problem at all, just provide build with 3 major compilers gcc/clang (due to 
binary compatability) and Visual Studio
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/YJF3TJARY3BRTQ5WVPCZIWQ4XWXVB45Y/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2022-01-16 Thread Denis Kotov
Stephen J. Turnbull wrote:
> You take a hunk of the standard library (in this case it would have to
> be an accelerator written in C since you want to compare C++ vs. C) or
> interpreter code, and translate it to the new syntax.
> Now, *INCREF and friends are frequently cited as annoyances or even
> warts, so your suggestion of std::shared _ptr<> seemed plausible to
> me.  But Antoine peeked at it and points out it's not that easy, for
> performance reasons you can't use it "as is".  It's true that you
> could reimplement it, but then it's not std::shared_ptr<> any more and
> the only benefit left is that it looks familiar to C++ programmers
> (and may mislead *them* into thinking about it as if it were exactly
> std::shared_ptr<>).

Re-implementing of std::shared _ptr<> for single thread is smallest of the 
problems

> And that's why you need to do more work than arguing that in principle
> C++ is just a better language than C.  We've been hearing that for 4
> decades now (at least we greybeards have), and we've discovered that
> for many existing applications, C++ may be better but the cost of
> converting large swaths of C code to equivalent C++ that passes all
> tests is too big.  Python may very well be one of them.
> So if you're not going to do the work to demonstrate big wins from
> using C++ instead of C in actual Python implementation code, I think
> you're wasting your posts.

I thought about it, but will CPython accept the PR for this changes if it would 
show benefits ?
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/HHXVWQ4GJSBQFYBVW6IH42DE75BHUXVR/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2022-04-29 Thread Denis Kotov
> From huge codebase experience with C++, it does not cause
significantly better (1) Readabillity or (2) Maintainability on its own
compared to C

I would argue with you on that ...
RAII is fundamental C++ feature that improves Maintainability !!
Also readability is much better because you work with object that will be 
compiled in the same code if you will write it by hands, for example: 
std::vector
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/CZF33DKRTAMNVIDAZD2BPVVK4PVCVYM6/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2022-04-30 Thread Denis Kotov
Stephen J. Turnbull wrote:
> The point of C++ standard support level is linking CPython to external
> codebases using C++, and at least for the standard CPython currently
> supports, the C++ ABI is specific to each compiler and version (for
> some compilers), right?

Yes, C++ ABI is specific to each compiler, but it is not a problem, because you 
will anyway recompile CPython for each compiler !!
Also g++ and clang++ has the same C++ ABI !!

Usually people say that C++ not fit in CPython not knowing C++, it is common 
thing in psychology:
https://en.wikipedia.org/wiki/I_know_that_I_know_nothing
https://medium.com/@cogitality/the-dunning-kruger-effect-a-paradox-that-doesnt-apply-to-me-e48de7b3f77f

Lets consider the advantages of C++:
1) C++ has objects, Python has objects, C do not have objects (struct is not 
object in term of OOP)
2) C++ has templates that allow to generate for free function specialization to 
improve performance
3) C++ has move semantic and switching to C++ you have move object for free !!
4) C++ has RAII (equivalent to CPython __del__), that works the same way to 
5) ...

and so on ...
... but i will not convince you because it is also another psychology stuff, if 
you what to believe in something, you will try to find evidences for proving 
your theory, see also:
https://www.youtube.com/watch?v=vUzGV4F7He8

Please, to not take it personally, i just shared my thought about all of this 
discussion ...

I just optimistic all my life that is why I try to impact, even if it is almost 
impossible )))
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/EQ5ETXJKK4DA4APAMQPGDVLRQYBPCA23/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2022-10-17 Thread Denis Kotov
Stephen J. Turnbull wrote:
> Denis Kotov writes:
> > Usually people say that C++ not fit in CPython not knowing C++,
> > That's not the issue.  There are plenty of people who know C++ who say
> the benefits of C++ are not worth the bugs, the effort, and the plain
> old churn that a rewrite in C++ (even if incremental) would require.

I am not sure about this one ...
For example, PyObject is much better to implement using C++ class, it will 
bring RAII that will reduce number of issues not free memory in CPython
See:
https://youtube.com/clip/UgkxyNe_dsZKinT_RT3UGb-BaP0SnvKteo2o

Without RAII - introduced the most dangerous errors !!
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/7LNKR4P3TKNBOFWQMNLIDHH3NYAU5H6I/
Code of Conduct: http://python.org/psf/codeofconduct/


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

2022-10-17 Thread Denis Kotov
Stephen J. Turnbull wrote:
> Denis Kotov writes:
> > See:
> > https://youtube.com/clip/UgkxyNe_dsZKinT_RT3UGb-BaP0SnvKteo2o
> > No thanks, if it's not text I'm not going to look at it.  I don't have
> time to watch videos with no explanation, and best guess is 90% of it
> I already know, just as I don't think you've yet written anything I
> didn't already know.

It is just 10-20 seconds, I used YouTube Shorts to slice it :)
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/OYVZG7ZDPO6IYTQSV4YP5S56A3RKRIVC/
Code of Conduct: http://python.org/psf/codeofconduct/