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
Gwenaël Samain
cython
Commits
03337615
Commit
03337615
authored
Jun 17, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the first code snippet of the extension_types.rst to the examples directory for testing.
parent
f1815e7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
docs/examples/userguide/extension_types/shrubbery.pyx
docs/examples/userguide/extension_types/shrubbery.pyx
+12
-0
docs/src/userguide/extension_types.rst
docs/src/userguide/extension_types.rst
+2
-14
No files found.
docs/examples/userguide/extension_types/shrubbery.pyx
0 → 100644
View file @
03337615
from
__future__
import
print_function
cdef
class
Shrubbery
:
cdef
int
width
,
height
def
__init__
(
self
,
w
,
h
):
self
.
width
=
w
self
.
height
=
h
def
describe
(
self
):
print
(
"This shrubbery is"
,
self
.
width
,
"by"
,
self
.
height
,
"cubits."
)
docs/src/userguide/extension_types.rst
View file @
03337615
...
...
@@ -12,21 +12,9 @@ Introduction
As well as creating normal user-defined classes with the Python class
statement, Cython also lets you create new built-in Python types, known as
extension types. You define an extension type using the :keyword:`cdef` class
statement. Here's an example:
:
statement. Here's an example:
from __future__ import print_function
cdef class Shrubbery:
cdef int width, height
def __init__(self, w, h):
self.width = w
self.height = h
def describe(self):
print("This shrubbery is", self.width,
"by", self.height, "cubits.")
.. literalinclude:: ../../examples/userguide/extension_types/shrubbery.pyx
As you can see, a Cython extension type definition looks a lot like a Python
class definition. Within it, you use the def statement to define methods that
...
...
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