Commit 28a0408f authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Made the example more robust and also added a note for sharing entension types...

Made the example more robust and also added a note for sharing entension types as this is non-trivial.
parent 0f6795d0
from __future__ import print_function
cdef class Shrubbery:
def __init__(self, w, h):
self.width = w
self.height = h
def describe(self):
print("This shrubbery is", self.width,
"by", self.height, "cubits.")
......@@ -115,6 +115,14 @@ The same consideration applies to local variables, for example:
.. literalinclude:: ../../examples/userguide/extension_types/shrubbery_2.pyx
.. note::
We here ``cimport`` the class :class:`Shrubbery`, and this is necessary
to declare the type at compile time. To be able to ``cimport`` an extension type,
we split the class definition into two parts, one in a definition file and
the other in the corresponding implementation file. You should read
:ref:`sharing_extension_types` to learn to do that.
Type Testing and Casting
------------------------
......
......@@ -203,6 +203,7 @@ example:
this object from Python, nor can you use it from Cython using a normal import
statement; you have to use :keyword:`cimport`.
.. _sharing_extension_types:
Sharing Extension Types
=======================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment