[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

[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

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Tim Peters
[Guido] > I don't think there's a way to do a PGO build from Visual Studio; but > a command prompt in the repo can do it using `PCbuild\build.bat --pgo`. > Just be patient with it. Thanks! That worked, and was easy, and gave me an executable that runs "// 10" at supernatural speed. Alas, Visual

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Gregory P. Smith
On Sun, Jan 16, 2022 at 1:51 PM Mark Dickinson wrote: > On Sun, Jan 16, 2022 at 9:28 PM Guido van Rossum wrote: > >> Does the optimization for //10 actually help in the real world? [...] >> > > Yep, I don't know. If 10 is *not* the most common small divisor in real > world code, it must at

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Guido van Rossum
On Sun, Jan 16, 2022 at 2:21 PM Tim Peters wrote: > I have to believe the same is true under Visual Studio 2019, but > offhand don't know how to prove that. I understand Steve uses PGO to > build the python.org Windows release, but I've never done that - the > "Release build" configuration I get

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Tim Peters
[Tim, incidentally notes that passing 10 as the divisor to inplace_divrem1() is "impossibly fast" on Windows, consuming less than a third the time as when passing seemingly any other divisor] [Mark Dickinson, discovers much the same is true under other, but not all, Linux-y builds, due to the

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Mark Dickinson
On Sun, Jan 16, 2022 at 9:28 PM Guido van Rossum wrote: > Does the optimization for //10 actually help in the real world? [...] > Yep, I don't know. If 10 is *not* the most common small divisor in real world code, it must at least rank in the top five. I might hazard a guess that division by 2

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Guido van Rossum
As a bystander, this is all fascinating (I had actually anticipated that the //10 optimization came from PGO). Does the optimization for //10 actually help in the real world? It would if people did a lot of manual conversion to decimal, which is easiest expressed using //10. But presumably for

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Mark Dickinson
On Sun, Jan 16, 2022 at 12:08 PM Mark Dickinson wrote: > So gcc is anticipating divisions by 10 and introducing special-case > divide-by-reciprocal-multiply code for that case, and presumably the > profile generated for the PGO backs up this being a common enough case, so > we end up with the

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Mark Dickinson
On Sun, Jan 16, 2022 at 4:11 PM Terry Reedy wrote: > > > https://stackoverflow.com/questions/41183935/why-does-gcc-use-multiplication-by-a-strange-number-in-implementing-integer-divi > > and > > > https://stackoverflow.com/questions/30790184/perform-integer-division-using-multiplication > > have

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Terry Reedy
On 1/16/2022 7:08 AM, Mark Dickinson wrote: Now /that/ I certainly wasn't expecting. I don't see the same effect on macOS / Clang, whether compiling with --enable-optimizations or not; this appears to be a GCC innovation. And indeed, as Tim suggested, it turns out that there's no division

[Python-Dev] Re: Is anyone using 15-bit PyLong digits (PYLONG_BITS_IN_DIGIT=15)?

2022-01-16 Thread Mark Dickinson
On Sat, Jan 15, 2022 at 8:12 PM Tim Peters wrote: > Something is missing here, but can't guess what without seeing the > generated machine code.But I trust Mark will do that. > Welp, there goes my weekend. :-) $ python -m timeit -n 150 -s "x = 10**1000" "x//10" 150 loops, best of 5: