This document specifies the Python subset supported by HOPE.
The following NumPy types are supported
The while statement is supported as well as for loops but only with range(stop) or range(start, stop) resp. xrange:
for i in range(start, stop):
foo()
A function needs to have a fixed return type. HOPE currently supports scalar and array data types as return values.
The following code will not compile as the type of the return value may change depending on the execution:
@hope.jit
def incompatible_return(arg):
if arg > 10:
return 1
else:
return 2.3 # ERROR: Inconsistent return type
Call to pure Python functions are supported if the function
Then the called function is also compiled to c++ and included in the shared object regardless where the function was defined originally.
Assignment
Assign | b = a |
Unary operators
UAdd | +a |
USub | -a |
Binary operators
Add | a + b |
Sub | a - b |
Mult | a * b |
Div | a / b |
FloorDiv | a // b |
Pow | a ** b |
Mod | a % b |
LShift | a << b |
RShift | a >> b |
BitOr | a | b |
BitXor | a ^ b |
BitAnd | a & b |
Augmented assign statements
AugAdd | a += b |
AugSub | a -= b |
AugMult | a *= b |
AugDiv | a /= b |
AugFloorDiv | a /= b |
AugPow | a **= b |
AugMod | a %= b |
AugLShift | a <<= b |
AugRShift | a <<= b |
AugBitOr | a | b |
AugBitXor | a ^ b |
AugBitAnd | a & b |
Comparison Operators
Eq | a == b |
NotEq | a != b |
Lt | a < b |
LtE | a <= b |
Gt | a > b |
GtE | a >= b |
Bool Operators
&& | a and b |
|| | a or b |
empty(shape[, dtype]) | Return a new array of given shape and type, without initializing entries. |
ones(shape[, dtype]) | Return a new array of given shape and type, filled with ones. |
zeros(shape[, dtype]) | Return a new array of given shape and type, filled with zeros. |
Trigonometric functions
sin(x) | Trigonometric sine, element-wise. |
cos(x) | Cosine elementwise. |
tan(x) | Compute tangent element-wise. |
arcsin(x) | Inverse sine, element-wise. |
arccos(x) | Trigonometric inverse cosine, element-wise. |
arctan(x) | Trigonometric inverse tangent, element-wise. |
Hyperbolic functions
sinh(x) | Hyperbolic sine, element-wise. |
cosh(x) | Hyperbolic cosine, element-wise. |
tanh(x) | Compute hyperbolic tangent element-wise. |
Exponents and logarithms
exp(x) | Calculate the exponential of all elements in the input array. |
Miscellaneous
sum(x) | Return the sum of array elements. |
sqrt(x) | Return the positive square-root of an array, element-wise. |
interp(x, xp, fp[, left, right]) | One-dimensional linear interpolation. |
ceil(x) | Return the ceiling of the input, element-wise. |
floor(x) | Return the floor of the input, element-wise. |
trunc(x) | Return the truncated value of the input, element-wise. |
pi | Returns the pi constant |
fabs | Compute the absolute values element-wise |
sign | Returns an element-wise indication of the sign of a number |
No attributes are supported at the moment