Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-10 Thread Nick Coghlan
On Tue, May 10, 2011 at 11:53 AM, Marvin Humphrey mar...@rectangular.com wrote: With regards to what actually happens to the reference count, I would argue that incremented and decremented are accurate descriptions.  * When a function returns an incremented object, that function has added    

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-09 Thread Nick Coghlan
On Fri, May 6, 2011 at 8:27 PM, Antoine Pitrou solip...@pitrou.net wrote: On Fri, 06 May 2011 13:28:11 +1200 Greg Ewing greg.ew...@canterbury.ac.nz wrote: Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: This is not always true, for example when the item is already

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-09 Thread Greg Ewing
Nick Coghlan wrote: One interesting aspect is that from the caller's point of view, a *new* reference to the relevant behaves like a borrowed reference for input parameters, but like a stolen reference for output parameters and return values. I think it's less confusing to use the term new

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-09 Thread Greg Ewing
Marvin Humphrey wrote: incremented: The caller has to account for an additional refcount. decremented: The caller has to account for a lost refcount. I'm not sure that really clarifies anything. These terms sound like they're talking about the reference count of the object, but if they

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-09 Thread Marvin Humphrey
On Tue, May 10, 2011 at 12:13:47PM +1200, Greg Ewing wrote: Nick Coghlan wrote: One interesting aspect is that from the caller's point of view, a *new* reference to the relevant behaves like a borrowed reference for input parameters, but like a stolen reference for output parameters and

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-09 Thread Marvin Humphrey
On Tue, May 10, 2011 at 01:28:04PM +1200, Greg Ewing wrote: Marvin Humphrey wrote: incremented: The caller has to account for an additional refcount. decremented: The caller has to account for a lost refcount. I'm not sure that really clarifies anything. These terms sound like they're

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-06 Thread Mark Shannon
s...@pobox.com wrote: Georg Let's remove the cruft, and only keep interesting info. This Georg will also make the file much more manageable. If I was to do this from scratch I'd think hard about annotating the source code. No matter how hard you try, if you keep this information

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-06 Thread Amaury Forgeot d'Arc
Le vendredi 6 mai 2011, Mark Shannon ma...@dcs.gla.ac.uk a écrit : What about #defining PY_STOLEN in some header? Then any stolen parameter can be prefixed with PY_STOLEN in signature. For return values, similarly #define PY_BORROWED. Header files are harder to parse, and I don't see how it

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-06 Thread Antoine Pitrou
On Fri, 06 May 2011 13:28:11 +1200 Greg Ewing greg.ew...@canterbury.ac.nz wrote: Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: This is not always true, for example when the item is already present in the dict. It's not important to know what the function does

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-06 Thread Mark Shannon
Antoine Pitrou wrote: On Fri, 06 May 2011 13:28:11 +1200 Greg Ewing greg.ew...@canterbury.ac.nz wrote: Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: This is not always true, for example when the item is already present in the dict. It's not important to know what

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-06 Thread Georg Brandl
On 06.05.2011 10:18, Amaury Forgeot d'Arc wrote: Le vendredi 6 mai 2011, Mark Shannon ma...@dcs.gla.ac.uk a écrit : What about #defining PY_STOLEN in some header? Then any stolen parameter can be prefixed with PY_STOLEN in signature. For return values, similarly #define PY_BORROWED.

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-06 Thread Georg Brandl
On 06.05.2011 12:27, Antoine Pitrou wrote: On Fri, 06 May 2011 13:28:11 +1200 Greg Ewing greg.ew...@canterbury.ac.nz wrote: Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: This is not always true, for example when the item is already present in the dict. It's

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Amaury Forgeot d'Arc
Hi, Le jeudi 5 mai 2011, Greg Ewing greg.ew...@canterbury.ac.nz a écrit : Amaury Forgeot d'Arc wrote: It's in the file Doc/data/refcounts.dat in some custom format. However, it doesn't seem to quite convey the same information. It lists the refcount effect on each parameter, but

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Guido van Rossum
On Thu, May 5, 2011 at 3:38 AM, Amaury Forgeot d'Arc amaur...@gmail.com wrote: Hi, Le jeudi 5 mai 2011, Greg Ewing greg.ew...@canterbury.ac.nz a écrit : Amaury Forgeot d'Arc wrote: It's in the file Doc/data/refcounts.dat in some custom format. However, it doesn't seem to quite convey

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Amaury Forgeot d'Arc
2011/5/5 Guido van Rossum gu...@python.org: Seems you're in agreement with this. IMO when references are borrowed it is not very interesting. The interesting thing is when calling a function *steals* a reference. The other important thing to know is whether the caller ends up owning the return

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Guido van Rossum
On Thu, May 5, 2011 at 10:17 AM, Amaury Forgeot d'Arc amaur...@gmail.com wrote: 2011/5/5 Guido van Rossum gu...@python.org: Seems you're in agreement with this. IMO when references are borrowed it is not very interesting. The interesting thing is when calling a function *steals* a reference.

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Georg Brandl
On 05.05.2011 19:00, Guido van Rossum wrote: On Thu, May 5, 2011 at 3:38 AM, Amaury Forgeot d'Arc amaur...@gmail.com wrote: Hi, Le jeudi 5 mai 2011, Greg Ewing greg.ew...@canterbury.ac.nz a écrit : Amaury Forgeot d'Arc wrote: It's in the file Doc/data/refcounts.dat in some custom

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Antoine Pitrou
On Thu, 5 May 2011 19:17:30 +0200 Amaury Forgeot d'Arc amaur...@gmail.com wrote: 2011/5/5 Guido van Rossum gu...@python.org: Seems you're in agreement with this. IMO when references are borrowed it is not very interesting. The interesting thing is when calling a function *steals* a

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Raymond Hettinger
On May 5, 2011, at 10:18 AM, Guido van Rossum wrote: On Thu, May 5, 2011 at 10:17 AM, Amaury Forgeot d'Arc amaur...@gmail.com wrote: 2011/5/5 Guido van Rossum gu...@python.org: Seems you're in agreement with this. IMO when references are borrowed it is not very interesting. The interesting

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Georg Brandl
On 05.05.2011 19:17, Amaury Forgeot d'Arc wrote: 2011/5/5 Guido van Rossum gu...@python.org: Seems you're in agreement with this. IMO when references are borrowed it is not very interesting. The interesting thing is when calling a function *steals* a reference. The other important thing to

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread Greg Ewing
Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: This is not always true, for example when the item is already present in the dict. It's not important to know what the function does to the object, Only the action on the reference is relevant. Yes, that's the whole

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-05 Thread skip
Georg Let's remove the cruft, and only keep interesting info. This Georg will also make the file much more manageable. If I was to do this from scratch I'd think hard about annotating the source code. No matter how hard you try, if you keep this information separate from the code and

[Python-Dev] Borrowed and Stolen References in API

2011-05-04 Thread Mark Shannon
Hi, The online documentation specifies which API function borrow and/or steal references (as opposed to the default behaviour). Yet, I cannot find this information anywhere in the source. Any clues as to where I should look? Cheers, Mark ___

[Python-Dev] Borrowed and Stolen References in API

2011-05-04 Thread Amaury Forgeot d'Arc
Hi, Le mercredi 4 mai 2011, Mark Shannon ma...@dcs.gla.ac.uk a écrit : The online documentation specifies which API function borrow and/or steal references (as opposed to the default behaviour). Yet, I cannot find this information anywhere in the source. Any clues as to where I should look?

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-04 Thread Greg Ewing
Mark Shannon wrote: The online documentation specifies which API function borrow and/or steal references (as opposed to the default behaviour). Yet, I cannot find this information anywhere in the source. There are comments in some places, e.g. in listobject.h: *** WARNING ***

Re: [Python-Dev] Borrowed and Stolen References in API

2011-05-04 Thread Greg Ewing
Amaury Forgeot d'Arc wrote: It's in the file Doc/data/refcounts.dat in some custom format. However, it doesn't seem to quite convey the same information. It lists the refcount effect on each parameter, but translating that into the notion of borrowed or stolen references seems to require