Commit f29ae73c authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2334 from gabrieldemarmiesse/pure_python_mode_1

Adding tests for "pure python mode" part 1
parents 1310d1eb 881d2c05
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 ...@@ -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 being compiled, it will be searched for :keyword:`cdef` classes and
:keyword:`cdef`/:keyword:`cpdef` functions and methods. The compiler will :keyword:`cdef`/:keyword:`cpdef` functions and methods. The compiler will
then convert the corresponding classes/functions/methods in the :file:`.py` 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): .. literalinclude:: ../../examples/tutorial/pure/A.py
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`::
cpdef int myfunction(int x, int y=*) and adds :file:`A.pxd`:
cdef double _helper(double a)
cdef class A: .. literalinclude:: ../../examples/tutorial/pure/A.pxd
cdef public int a,b
cpdef foo(self, double x)
then Cython will compile the :file:`A.py` as if it had been written as follows:: 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