Commit 881d2c05 authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Put a A.py and A.pxd from "pure python mode" in the examples directory for testing.

parent 5fadf79e
cpdef int myfunction(int x, int y=*)
cdef double _helper(double a)
cdef class A:
cdef public int a, b
cpdef foo(self, double x)
def myfunction(x, y=2):
a = x - y
return a + x * y
def _helper(a):
return a + 1
class A:
def __init__(self, b=0):
self.a = 3
self.b = b
def foo(self, x):
print(x + _helper(1.0))
......@@ -42,31 +42,13 @@ If a :file:`.pxd` file is found with the same name as the :file:`.py` file
being compiled, it will be searched for :keyword:`cdef` classes and
:keyword:`cdef`/:keyword:`cpdef` functions and methods. The compiler will
then convert the corresponding classes/functions/methods in the :file:`.py`
file to be of the declared type. Thus if one has a file :file:`A.py`::
file to be of the declared type. Thus if one has a file :file:`A.py`:
def myfunction(x, y=2):
a = x-y
return a + x * y
def _helper(a):
return a + 1
class A:
def __init__(self, b=0):
self.a = 3
self.b = b
def foo(self, x):
print(x + _helper(1.0))
and adds :file:`A.pxd`::
.. literalinclude:: ../../examples/tutorial/pure/A.py
cpdef int myfunction(int x, int y=*)
cdef double _helper(double a)
and adds :file:`A.pxd`:
cdef class A:
cdef public int a,b
cpdef foo(self, double x)
.. literalinclude:: ../../examples/tutorial/pure/A.pxd
then Cython will compile the :file:`A.py` as if it had been written as follows::
......
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