diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 52ce3fe7a889cf142a5562e17269bdc7c42d170b..031927e5db3b94ec2049a20271c8c58c2b3edf5c 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -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 diff --git a/docs/src/userguide/fusedtypes.rst b/docs/src/userguide/fusedtypes.rst index 4fce7c4bc9443cdb305efb604694ab6146fafc7f..132f86fa551900d2afcf4f3e69bb085086b6b89c 100644 --- a/docs/src/userguide/fusedtypes.rst +++ b/docs/src/userguide/fusedtypes.rst @@ -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[:, :]``.