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
7c7cc9da
Commit
7c7cc9da
authored
Jul 17, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs on static methods.
parent
fe73aba5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
docs/src/userguide/extension_types.rst
docs/src/userguide/extension_types.rst
+18
-1
docs/src/userguide/wrapping_CPlusPlus.rst
docs/src/userguide/wrapping_CPlusPlus.rst
+3
-2
No files found.
docs/src/userguide/extension_types.rst
View file @
7c7cc9da
...
...
@@ -345,7 +345,7 @@ functions, C methods are declared using :keyword:`cdef` or :keyword:`cpdef` inst
:keyword:`def`. C methods are "virtual", and may be overridden in derived
extension types. In addition, :keyword:`cpdef` methods can even be overridden by python
methods when called as C method. This adds a little to their calling overhead
compared to a :keyword:`cdef` methd::
compared to a :keyword:`cdef` meth
o
d::
# pets.pyx
cdef class Parrot:
...
...
@@ -382,6 +382,23 @@ method using the usual Python technique, i.e.::
Parrot.describe(self)
`cdef` methods can be declared static by using the @staticmethod decorator.
This can be especially useful for constructing classes that take non-Python
compatible types.::
cdef class OwnedPointer:
cdef void* ptr
cdef __dealloc__(self):
if ptr != NULL:
free(ptr)
@staticmethod
cdef create(void* ptr):
p = OwnedPointer()
p.ptr = ptr
return ptr
Forward-declaring extension types
===================================
...
...
docs/src/userguide/wrapping_CPlusPlus.rst
View file @
7c7cc9da
...
...
@@ -529,9 +529,10 @@ If the Rectangle class has a static member:
};
}
you can declare it
as a function living in the class namespace
, i.e.::
you can declare it
using the Python @staticmethod decorator
, i.e.::
cdef extern from "Rectangle.h" namespace "shapes::Rectangle":
cdef extern from "Rectangle.h" namespace "shapes":
@staticmethod
void do_something()
...
...
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