Commit 2d95923a authored by Mark Florisson's avatar Mark Florisson

Include more numeric types in cython.numeric, update documentation

parent dfdeb36e
......@@ -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
......
......@@ -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[:, :]``.
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