[Python-checkins] python/dist/src/Doc/api intro.tex, 1.3.24.1,
1.3.24.2
loewis at users.sourceforge.net
loewis at users.sourceforge.net
Thu Nov 6 16:07:49 EST 2003
Update of /cvsroot/python/python/dist/src/Doc/api
In directory sc8-pr-cvs1:/tmp/cvs-serv7179
Modified Files:
Tag: release23-maint
intro.tex
Log Message:
Patch #837322: Clarify owning, borrowing, stealing.
Index: intro.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/api/intro.tex,v
retrieving revision 1.3.24.1
retrieving revision 1.3.24.2
diff -C2 -d -r1.3.24.1 -r1.3.24.2
*** intro.tex 13 Oct 2003 17:48:23 -0000 1.3.24.1
--- intro.tex 6 Nov 2003 21:07:47 -0000 1.3.24.2
***************
*** 170,179 ****
The reference count behavior of functions in the Python/C API is best
! explained in terms of \emph{ownership of references}. Note that we
! talk of owning references, never of owning objects; objects are always
! shared! When a function owns a reference, it has to dispose of it
! properly --- either by passing ownership on (usually to its caller) or
! by calling \cfunction{Py_DECREF()} or \cfunction{Py_XDECREF()}. When
! a function passes ownership of a reference on to its caller, the
caller is said to receive a \emph{new} reference. When no ownership
is transferred, the caller is said to \emph{borrow} the reference.
--- 170,183 ----
The reference count behavior of functions in the Python/C API is best
! explained in terms of \emph{ownership of references}. Ownership
! pertains to references, never to objects (objects are not owned: they
! are always shared). "Owning a reference" means being responsible for
! calling Py_DECREF on it when the reference is no longer needed.
! Ownership can also be transferred, meaning that the code that receives
! ownership of the reference then becomes responsible for eventually
! decref'ing it by calling \cfunction{Py_DECREF()} or
! \cfunction{Py_XDECREF()} when it's no longer needed --or passing on
! this responsibility (usually to its caller).
! When a function passes ownership of a reference on to its caller, the
caller is said to receive a \emph{new} reference. When no ownership
is transferred, the caller is said to \emph{borrow} the reference.
More information about the Python-checkins
mailing list