class Float32Visitor(ast.NodeTransformer):

    def visit_Module(self, node):
        imp = ast.Import([ast.alias('numpy')])
node.body = [imp] + node.body
return node

def visit_Num(self, node):
    if not isinstance(node.n, float):
        return node
return ast.Call(func=ast.Attribute(value=ast.Name(id='numpy', ctx=ast.Load(
    )), attr='float32', ctx=ast.Load()), args=[node], keywords=[], starargs
    =None, kwargs=None)
32-bit floating point math in 64-bit Python