diff options
author | Stefan Behnel <scoder@users.berlios.de> | 2011-04-11 08:26:44 +0200 |
---|---|---|
committer | Stefan Behnel <scoder@users.berlios.de> | 2011-04-11 08:26:44 +0200 |
commit | 73009ce2a49154760ffb73b51dd181c6221202cb (patch) | |
tree | b3edd94e304e787280749450ce2dc4eb975dc2d7 /Cython/Includes | |
parent | ae9a7c0704a0622e074759be3a62233b6fc08ff8 (diff) | |
download | cython-73009ce2a49154760ffb73b51dd181c6221202cb.tar.gz |
doc fix in .pxd file
Diffstat (limited to 'Cython/Includes')
-rw-r--r-- | Cython/Includes/cpython/__init__.pxd | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Cython/Includes/cpython/__init__.pxd b/Cython/Includes/cpython/__init__.pxd index 356547ac9..bcf8b806c 100644 --- a/Cython/Includes/cpython/__init__.pxd +++ b/Cython/Includes/cpython/__init__.pxd @@ -24,15 +24,17 @@ # cdef extern from "Python.h": # PyObject* PyNumber_Add(PyObject *o1, PyObject *o2) # -# in your file after any .pxi includes. Cython will use the latest -# declaration. +# in your .pyx file or into a cimported .pxd file. You just have to +# use the one from the right (pxd-)namespace then. +# +# Cython automatically takes care of reference counting for anything +# of type object. # -# Cython takes care of this automatically for anything of type object. ## More precisely, I think the correct convention for -## using the Python/C API from Pyrex is as follows. +## using the Python/C API from Cython is as follows. ## ## (1) Declare all input arguments as type "object". This way no explicit -## <PyObject*> casting is needed, and moreover Pyrex doesn't generate +## <PyObject*> casting is needed, and moreover Cython doesn't generate ## any funny reference counting. ## (2) Declare output as object if a new reference is returned. ## (3) Declare output as PyObject* if a borrowed reference is returned. @@ -40,7 +42,7 @@ ## This way when you call objects, no cast is needed, and if the api ## calls returns a new reference (which is about 95% of them), then ## you can just assign to a variable of type object. With borrowed -## references if you do an explicit typecast to <object>, Pyrex generates an +## references if you do an explicit typecast to <object>, Cython generates an ## INCREF and DECREF so you have to be careful. However, you got a ## borrowed reference in this case, so there's got to be another reference ## to your object, so you're OK, as long as you relealize this |