Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Tony Flury via Python-list
On 26/01/2022 22:41, Barry wrote: Run python and your code under a debugger and check the ref count of the object as you step through the code. Don’t just step through your code but also step through the C python code. That will allow you to see how this works at a low level. Setting a watc

Re: mac app from a python script?

2022-01-26 Thread Dan Stromberg
On Wed, Jan 26, 2022 at 2:35 PM Barry wrote: > > > On 26 Jan 2022, at 05:17, Dan Stromberg wrote: > > > On Tue, Jan 25, 2022 at 6:41 PM Dan Stromberg wrote: > >> >> On Tue, Jan 25, 2022 at 2:23 PM Barry wrote: >> >>> >>> On 25 Jan 2022, at 02:56, Dan Stromberg wrote: >>> >>>  >>> >>> On Sun,

Re: Pandas or Numpy

2022-01-26 Thread Marco Sulla
On Mon, 24 Jan 2022 at 05:37, Dennis Lee Bieber wrote: > Note that the comparison warns that /indexing/ in pandas can be slow. > If your manipulation is always "apply operationX to columnY" it should be > okay -- but "apply operationX to the nth row of columnY", and repeat for > other rows

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Barry
> On 25 Jan 2022, at 23:50, Tony Flury wrote: > >  > > >> On 25/01/2022 22:28, Barry wrote: >> On 25 Jan 2022, at 14:50, Tony Flury via Python-list wrote:  > On 20/01/2022 23:12, Chris Angelico wrote: >>> On Fri, 21 Jan 2022 at 10:10, Greg Ewing >>> wro

Re: mac app from a python script?

2022-01-26 Thread Barry
> On 26 Jan 2022, at 05:17, Dan Stromberg wrote: > >  > >> On Tue, Jan 25, 2022 at 6:41 PM Dan Stromberg wrote: >> >>> On Tue, Jan 25, 2022 at 2:23 PM Barry wrote: >>> > On 25 Jan 2022, at 02:56, Dan Stromberg wrote: >  > On Sun, Jan 23, 2022 at 1:37 PM Barry wr

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Greg Ewing
The convention for refcounting in CPython is that a function takes borrowed references as arguments and returns a new reference. The 'self' argument passed in is a borrowed reference. If you want to return it, you need to create a new reference by increfing it. So what you have written is just t

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Tony Flury via Python-list
On 26/01/2022 08:20, Chris Angelico wrote: On Wed, 26 Jan 2022 at 19:04, Tony Flury via Python-list wrote: So according to that I should increment twice if and only if the calling code is using the result - which you can't tell in the C code - which is very odd behaviour. No, the return valu

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Chris Angelico
On Wed, 26 Jan 2022 at 19:04, Tony Flury via Python-list wrote: > > So according to that I should increment twice if and only if the calling > code is using the result - which you can't tell in the C code - which is > very odd behaviour. No, the return value from your C function will *always* hav

Re: Puzzling behaviour of Py_IncRef

2022-01-26 Thread Tony Flury via Python-list
On 26/01/2022 01:29, MRAB wrote: On 2022-01-25 23:50, Tony Flury via Python-list wrote: On 25/01/2022 22:28, Barry wrote: On 25 Jan 2022, at 14:50, Tony Flury via Python-list  wrote:  On 20/01/2022 23:12, Chris Angelico wrote: On Fri, 21 Jan 2022 at 10:10, Greg Ewing  wrote: On 20/01/