Commit 36dfbbca authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2330 from gabrieldemarmiesse/test_cdef_classes_2

Added tests for cdef_classes.rst. Part 2.
parents 28bb1ffd 60ae2777
cdef class Function:
cpdef double evaluate(self, double x) except *:
return 0
...@@ -27,11 +27,9 @@ Cython code and pure Python code. ...@@ -27,11 +27,9 @@ Cython code and pure Python code.
So far our integration example has not been very useful as it only So far our integration example has not been very useful as it only
integrates a single hard-coded function. In order to remedy this, integrates a single hard-coded function. In order to remedy this,
with hardly sacrificing speed, we will use a cdef class to represent a with hardly sacrificing speed, we will use a cdef class to represent a
function on floating point numbers:: function on floating point numbers:
cdef class Function: .. literalinclude:: ../../examples/tutorial/cdef_classes/math_function_2.pyx
cpdef double evaluate(self, double x) except *:
return 0
The directive cpdef makes two versions of the method available; one The directive cpdef makes two versions of the method available; one
fast for use from Cython and one slower for use from Python. Then:: fast for use from Cython and one slower for use from Python. Then::
......
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