Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
73009ce2
Commit
73009ce2
authored
Apr 11, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc fix in .pxd file
parent
ae9a7c07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
Cython/Includes/cpython/__init__.pxd
Cython/Includes/cpython/__init__.pxd
+8
-6
No files found.
Cython/Includes/cpython/__init__.pxd
View file @
73009ce2
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment