Commit 0c329bac authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2368 from gabrieldemarmiesse/test_fused_types_1

Added tests to "Fused types (templates)" part 1
parents a0162a12 338e6910
from __future__ import print_function
cimport cython
ctypedef fused char_or_float:
cython.char
cython.float
cpdef char_or_float plus_one(char_or_float var):
return var + 1
def show_me():
cdef:
cython.char a = 127
cython.float b = 127
print('char', plus_one(a))
print('float', plus_one(b))
......@@ -24,26 +24,7 @@ Java / C#.
Quickstart
==========
::
from __future__ import print_function
cimport cython
ctypedef fused char_or_float:
cython.char
cython.float
cpdef char_or_float plus_one(char_or_float var):
return var + 1
def show_me():
cdef:
cython.char a = 127
cython.float b = 127
print('char', plus_one(a))
print('float', plus_one(b))
.. literalinclude:: ../../examples/userguide/fusedtypes/char_or_float.pyx
This gives::
......
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