Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
0c329bac
Commit
0c329bac
authored
Jun 20, 2018
by
scoder
Committed by
GitHub
Jun 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2368 from gabrieldemarmiesse/test_fused_types_1
Added tests to "Fused types (templates)" part 1
parents
a0162a12
338e6910
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
20 deletions
+19
-20
docs/examples/userguide/fusedtypes/char_or_float.pyx
docs/examples/userguide/fusedtypes/char_or_float.pyx
+18
-0
docs/src/userguide/fusedtypes.rst
docs/src/userguide/fusedtypes.rst
+1
-20
No files found.
docs/examples/userguide/fusedtypes/char_or_float.pyx
0 → 100644
View file @
0c329bac
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
))
docs/src/userguide/fusedtypes.rst
View file @
0c329bac
...
@@ -24,26 +24,7 @@ Java / C#.
...
@@ -24,26 +24,7 @@ Java / C#.
Quickstart
Quickstart
==========
==========
::
.. literalinclude:: ../../examples/userguide/fusedtypes/char_or_float.pyx
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))
This gives::
This gives::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment