[Python-Dev] Re: Using the Python C API in C++

2022-05-03 Thread Victor Stinner
Hi Antoine, I'm in favor of making the C API more strict. The limited C API of Python 3.11 no longer cast arguments to PyObject* ! The caller must now cast to PyObject*: see PEP 670 "convert macros to functions". Converting macros to static inline functions (PEP 670) is already an important chang

[Python-Dev] Re: Using the Python C API in C++

2022-05-03 Thread Antoine Pitrou
On Mon, 2 May 2022 15:21:24 +0200 Victor Stinner wrote: > > Slowly, more and more tests can be added. For example, this change fixing > compiler warnings when passing "const PyObject*" to Python C API functions > adds tests to _testcppext.cpp: > https://github.com/python/cpython/pull/92138 Doesn

[Python-Dev] Re: Using the Python C API in C++

2022-05-02 Thread Steve Dower
On 5/2/2022 2:21 PM, Victor Stinner wrote: Maybe it should be made optional, but so far I failed to test if distutils has an available C++ compiler. Considering the current status of distutils, you should probably put that check in configure or the Makefile and build the extension from there

[Python-Dev] Re: Using the Python C API in C++

2022-05-02 Thread Victor Stinner
Hi, I merged the best basic tests to make sure that using the Python C API in C++ does not emit compiler warnings: * Code: https://github.com/python/cpython/blob/main/Lib/test/_testcppext.cpp * Test: https://github.com/python/cpython/blob/main/Lib/test/test_cppext.py The code is only built to ch

[Python-Dev] Re: Using the Python C API in C++

2022-04-29 Thread Victor Stinner
Hi, The C++ version was discussed in the 2nd link that I gave in my first message: https://github.com/python/cpython/issues/91321 Gregory wrote "If we can conditionally test new things based on C++XX version, accumulating modern issue regression tests seems useful. Otherwise 11 at minimum." Anot

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread h . vetinari
> Not for me to answer, I'm not a proponent of the change. I'm sure if > you read past discussions here and on Discourse you'll find answers > from the people who studied the problem carefully. The opening mail proposed C++11 without rationale or references. I did search the archives and discours

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread h . vetinari
> I work on Apache Arrow, where the C++ parts require C++11 (and we can't go further than this for now because of R compatibility concerns). Thanks for the datapoint, that's reasonable of course (though I'll note you're using abseil at least through grpc, and abseil is scheduled to remove C++11

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread Antoine Pitrou
On Thu, 28 Apr 2022 17:52:40 +0200 Victor Stinner wrote: > Recently, a issue about C++20 compatibility was reported: > > "The Python library will not compile with a C++2020 compiler because > the code uses the reserved “module” keyword" > https://github.com/python/cpython/issues/83536 > > In fa

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread Victor Stinner
Recently, a issue about C++20 compatibility was reported: "The Python library will not compile with a C++2020 compiler because the code uses the reserved “module” keyword" https://github.com/python/cpython/issues/83536 In fact, after a long study, Python C API is *not* affected by this issue. Usi

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread Antoine Pitrou
As a data point, I don't remember that recent versions of CPython brought any particular pain for PyArrow, which is a set of bindings written in Cython around some C++ core library code. Regards Antoine. On Wed, 27 Apr 2022 18:31:13 +0200 Victor Stinner wrote: > Hi, > > If you got issues wi

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread Antoine Pitrou
On Thu, 28 Apr 2022 22:03:25 +0900 "Stephen J. Turnbull" wrote: > h.vetin...@gmx.com writes: > > > While I don't know who proposed C++11 or where, I'd therefore like > > to propose to move to _at least_ C++14. > > What benefits does this have for Python development? Let me second that quest

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread Victor Stinner
Since we are you talking about tests, we can easily run the tests on multiple C++ versions. But we have to start somewhere, so I propose to start with C++11. More C++ versions can be tested later. Victor On Thu, Apr 28, 2022 at 5:54 AM wrote: > > > In terms of C++ version, it was proposed to tar

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread Stephen J. Turnbull
h.vetin...@gmx.com writes: > > > While I don't know who proposed C++11 or where, I'd therefore like > > > to propose to move to _at least_ C++14. > > > > What benefits does this have for Python development? > > Likewise I can ask what benefits choosing C++11 would have? Not for me to answ

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread h . vetinari
> > While I don't know who proposed C++11 or where, I'd therefore like > > to propose to move to _at least_ C++14. > > What benefits does this have for Python development? Likewise I can ask what benefits choosing C++11 would have? In general, I think standards and compilers need version hygiene

[Python-Dev] Re: Using the Python C API in C++

2022-04-28 Thread Stephen J. Turnbull
h.vetin...@gmx.com writes: > While I don't know who proposed C++11 or where, I'd therefore like > to propose to move to _at least_ C++14. What benefits does this have for Python development? ___ Python-Dev mailing list -- python-dev@python.org To uns

[Python-Dev] Re: Using the Python C API in C++

2022-04-27 Thread h . vetinari
> In terms of C++ version, it was proposed to target C++11. GCC 5 has full C++14 support (one library functionality missing), and so does VS2015 onwards as well as Clang 3.4, see https://en.cppreference.com/w/cpp/compiler_support I doubt that any older compilers are in use _anywhere_ in reasonab