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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2d95923a
Commit
2d95923a
authored
Oct 29, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include more numeric types in cython.numeric, update documentation
parent
dfdeb36e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+7
-2
docs/src/userguide/fusedtypes.rst
docs/src/userguide/fusedtypes.rst
+15
-2
No files found.
Cython/Compiler/PyrexTypes.py
View file @
2d95923a
...
...
@@ -3201,11 +3201,16 @@ c_py_buffer_ptr_type = CPtrType(c_py_buffer_type)
# Not sure whether the unsigned versions and 'long long' should be in there
# long long requires C99 and might be slow, and would always get preferred
# when specialization happens through calling and not indexing
cy_integral_type
=
FusedType
([
c_int_type
,
c_long_type
],
name
=
"integral"
)
cy_integral_type
=
FusedType
([
c_short_type
,
c_int_type
,
c_long_type
],
name
=
"integral"
)
# Omitting long double as it might be slow
cy_floating_type
=
FusedType
([
c_float_type
,
c_double_type
],
name
=
"floating"
)
cy_numeric_type
=
FusedType
([
c_long_type
,
cy_numeric_type
=
FusedType
([
c_short_type
,
c_int_type
,
c_long_type
,
c_float_type
,
c_double_type
,
c_float_complex_type
,
c_double_complex_type
],
name
=
"numeric"
)
# buffer-related structs
...
...
docs/src/userguide/fusedtypes.rst
View file @
2d95923a
...
...
@@ -111,9 +111,9 @@ Built-in Fused Types
====================
There are some built-in fused types available for convenience, these are::
cython.integral # int, long
cython.integral #
short,
int, long
cython.floating # float, double
cython.numeric #
long, double
, double complex
cython.numeric #
short, int, long, float, double, float complex
, double complex
Casting Fused Functions
=======================
...
...
@@ -178,3 +178,16 @@ It would usually be preferred to index like this, however::
Although the latter will select the biggest types for ``int`` and ``float`` from Python space, as they are
not type identifiers but builtin types there. Passing ``cython.int`` and ``cython.float`` would resolve that,
however.
For memoryview indexing from python space you have to use strings instead of types::
ctypedef fused my_fused_type:
int[:, ::1]
float[:, ::1]
def func(my_fused_type array):
...
my_fused_type['int[:, ::1]'](myarray)
The same goes for when using e.g. ``cython.numeric[:, :]``.
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