[Python-Dev] Re: Decreasing refcount for locals before popping frame

2022-04-28 Thread Malthe
Pablo Galindo Salgado wrote: > As it has been mentioned there is no guarantee that your variable will even > be finalized (or even destroyed) after the frame finishes. For example, if > your variable goes into a reference cycle for whatever reason it may not be > cleared until a GC run happens

[Python-Dev] Re: Decreasing refcount for locals before popping frame

2022-04-28 Thread Malthe
Dennis Sweeney wrote: > I don't know if there's anything specifically stopping this, but from what I > understand, the precise moment that a finalizer gets called is unspecified, > so relying on any sort of behavior there is undefined and non-portable. > Implementations like PyPy don't always

[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

[Python-Dev] Re: Decreasing refcount for locals before popping frame

2022-04-28 Thread Pablo Galindo Salgado
As it has been mentioned there is no guarantee that your variable will even be finalized (or even destroyed) after the frame finishes. For example, if your variable goes into a reference cycle for whatever reason it may not be cleared until a GC run happens (and in some situations it may not even

[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: Decreasing refcount for locals before popping frame

2022-04-28 Thread Dennis Sweeney
I don't know if there's anything specifically stopping this, but from what I understand, the precise moment that a finalizer gets called is unspecified, so relying on any sort of behavior there is undefined and non-portable. Implementations like PyPy don't always use reference counting, so

[Python-Dev] Decreasing refcount for locals before popping frame

2022-04-28 Thread Malthe
Consider this example code: def test(): a = A() test() Currently, the locals (i.e. `a`) are cleared only after the function has returned: If we attach a finalizer to `a` immediately after the declaration then the frame stack available via `sys._getframe()` inside the finalizer function

[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

[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.

[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

[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

[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

[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

[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

[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