Documentation

hope.jit(fkt)

Compiles a function to native code and return the optimized function. The new function has the performance of a compiled function written in C.

Parameters:fkt (function) – function to compile to c
Returns:function – optimized function

This function can either be used as decorator

@jit
def sum(x, y):
    return x + y

or as a normal function

def sum(x, y):
    return x + y
sum_opt = jit(sum)
hope.serialize(obj, name)

Write a pickled representation of obj to a file named name inside hope.config.prefix

Parameters:
  • obj (mixed) – arbitrary object to serialize
  • name (str) – name of the object
hope.unserialize(name)

Read an object named name form hope.config.prefix. If the file does not exits unserialize returns None

Parameters:name (str) – name of the object
Returns:mixed – unserialized object

hope.config

hope.config.cxxflags = [u'-Wall', u'-Wno-unused-variable', u'-march=native', u'-stdlib=libc++', u'-std=c++11']

List of c++ compiler flags. Normally hope does determing the right flags itself.

hope.config.hopeless = False

Disable hope. If hope.config.hopeless is True, hope.jit return the original function. Use this function for debug purpos

hope.config.keeptemp = False

Keep the intermediate c++ source and compiler output generated during compilation.

hope.config.optimize = False

Use ‘’‘sympy’‘’ to simplify expression and exptract common subexpression detection

hope.config.prefix = u'.hope'

Prefix of the folder hope saves all data in.

hope.config.rangecheck = False

Check if indeces are out of bounds

hope.config.verbose = False

Print a intermediate representation of each function during compilation.