repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
serge-sans-paille/pythran
pythran/types/type_dependencies.py
pytype_to_deps_hpp
def pytype_to_deps_hpp(t): """python -> pythonic type hpp filename.""" if isinstance(t, List): return {'list.hpp'}.union(pytype_to_deps_hpp(t.__args__[0])) elif isinstance(t, Set): return {'set.hpp'}.union(pytype_to_deps_hpp(t.__args__[0])) elif isinstance(t, Dict): tkey, tvalue ...
python
def pytype_to_deps_hpp(t): """python -> pythonic type hpp filename.""" if isinstance(t, List): return {'list.hpp'}.union(pytype_to_deps_hpp(t.__args__[0])) elif isinstance(t, Set): return {'set.hpp'}.union(pytype_to_deps_hpp(t.__args__[0])) elif isinstance(t, Dict): tkey, tvalue ...
[ "def", "pytype_to_deps_hpp", "(", "t", ")", ":", "if", "isinstance", "(", "t", ",", "List", ")", ":", "return", "{", "'list.hpp'", "}", ".", "union", "(", "pytype_to_deps_hpp", "(", "t", ".", "__args__", "[", "0", "]", ")", ")", "elif", "isinstance", ...
python -> pythonic type hpp filename.
[ "python", "-", ">", "pythonic", "type", "hpp", "filename", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L17-L43
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
pytype_to_deps
def pytype_to_deps(t): """ python -> pythonic type header full path. """ res = set() for hpp_dep in pytype_to_deps_hpp(t): res.add(os.path.join('pythonic', 'types', hpp_dep)) res.add(os.path.join('pythonic', 'include', 'types', hpp_dep)) return res
python
def pytype_to_deps(t): """ python -> pythonic type header full path. """ res = set() for hpp_dep in pytype_to_deps_hpp(t): res.add(os.path.join('pythonic', 'types', hpp_dep)) res.add(os.path.join('pythonic', 'include', 'types', hpp_dep)) return res
[ "def", "pytype_to_deps", "(", "t", ")", ":", "res", "=", "set", "(", ")", "for", "hpp_dep", "in", "pytype_to_deps_hpp", "(", "t", ")", ":", "res", ".", "add", "(", "os", ".", "path", ".", "join", "(", "'pythonic'", ",", "'types'", ",", "hpp_dep", "...
python -> pythonic type header full path.
[ "python", "-", ">", "pythonic", "type", "header", "full", "path", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L46-L52
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.prepare
def prepare(self, node): """ Add nodes for each global declarations in the result graph. No edges are added as there are no type builtin type dependencies. """ super(TypeDependencies, self).prepare(node) for v in self.global_declarations.values(): self.result...
python
def prepare(self, node): """ Add nodes for each global declarations in the result graph. No edges are added as there are no type builtin type dependencies. """ super(TypeDependencies, self).prepare(node) for v in self.global_declarations.values(): self.result...
[ "def", "prepare", "(", "self", ",", "node", ")", ":", "super", "(", "TypeDependencies", ",", "self", ")", ".", "prepare", "(", "node", ")", "for", "v", "in", "self", ".", "global_declarations", ".", "values", "(", ")", ":", "self", ".", "result", "."...
Add nodes for each global declarations in the result graph. No edges are added as there are no type builtin type dependencies.
[ "Add", "nodes", "for", "each", "global", "declarations", "in", "the", "result", "graph", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L237-L246
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_any_conditionnal
def visit_any_conditionnal(self, node1, node2): """ Set and restore the in_cond variable before visiting subnode. Compute correct dependencies on a value as both branch are possible path. """ true_naming = false_naming = None try: tmp = self.naming....
python
def visit_any_conditionnal(self, node1, node2): """ Set and restore the in_cond variable before visiting subnode. Compute correct dependencies on a value as both branch are possible path. """ true_naming = false_naming = None try: tmp = self.naming....
[ "def", "visit_any_conditionnal", "(", "self", ",", "node1", ",", "node2", ")", ":", "true_naming", "=", "false_naming", "=", "None", "try", ":", "tmp", "=", "self", ".", "naming", ".", "copy", "(", ")", "for", "expr", "in", "node1", ":", "self", ".", ...
Set and restore the in_cond variable before visiting subnode. Compute correct dependencies on a value as both branch are possible path.
[ "Set", "and", "restore", "the", "in_cond", "variable", "before", "visiting", "subnode", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L248-L290
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_FunctionDef
def visit_FunctionDef(self, node): """ Initialize variable for the current function to add edges from calls. We compute variable to call dependencies and add edges when returns are reach. """ # Ensure there are no nested functions. assert self.current_function is...
python
def visit_FunctionDef(self, node): """ Initialize variable for the current function to add edges from calls. We compute variable to call dependencies and add edges when returns are reach. """ # Ensure there are no nested functions. assert self.current_function is...
[ "def", "visit_FunctionDef", "(", "self", ",", "node", ")", ":", "assert", "self", ".", "current_function", "is", "None", "self", ".", "current_function", "=", "node", "self", ".", "naming", "=", "dict", "(", ")", "self", ".", "in_cond", "=", "False", "se...
Initialize variable for the current function to add edges from calls. We compute variable to call dependencies and add edges when returns are reach.
[ "Initialize", "variable", "for", "the", "current", "function", "to", "add", "edges", "from", "calls", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L292-L305
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_Return
def visit_Return(self, node): """ Add edge from all possible callee to current function. Gather all the function call that led to the creation of the returned expression and add an edge to each of this function. When visiting an expression, one returns a list of frozensets. Eac...
python
def visit_Return(self, node): """ Add edge from all possible callee to current function. Gather all the function call that led to the creation of the returned expression and add an edge to each of this function. When visiting an expression, one returns a list of frozensets. Eac...
[ "def", "visit_Return", "(", "self", ",", "node", ")", ":", "if", "not", "node", ".", "value", ":", "return", "for", "dep_set", "in", "self", ".", "visit", "(", "node", ".", "value", ")", ":", "if", "dep_set", ":", "for", "dep", "in", "dep_set", ":"...
Add edge from all possible callee to current function. Gather all the function call that led to the creation of the returned expression and add an edge to each of this function. When visiting an expression, one returns a list of frozensets. Each element of the list is linked to a possi...
[ "Add", "edge", "from", "all", "possible", "callee", "to", "current", "function", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L307-L327
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_Assign
def visit_Assign(self, node): """ In case of assignment assign value depend on r-value type dependencies. It is valid for subscript, `a[i] = foo()` means `a` type depend on `foo` return type. """ value_deps = self.visit(node.value) for target in node.targets: ...
python
def visit_Assign(self, node): """ In case of assignment assign value depend on r-value type dependencies. It is valid for subscript, `a[i] = foo()` means `a` type depend on `foo` return type. """ value_deps = self.visit(node.value) for target in node.targets: ...
[ "def", "visit_Assign", "(", "self", ",", "node", ")", ":", "value_deps", "=", "self", ".", "visit", "(", "node", ".", "value", ")", "for", "target", "in", "node", ".", "targets", ":", "name", "=", "get_variable", "(", "target", ")", "if", "isinstance",...
In case of assignment assign value depend on r-value type dependencies. It is valid for subscript, `a[i] = foo()` means `a` type depend on `foo` return type.
[ "In", "case", "of", "assignment", "assign", "value", "depend", "on", "r", "-", "value", "type", "dependencies", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L331-L342
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_AugAssign
def visit_AugAssign(self, node): """ AugAssigned value depend on r-value type dependencies. It is valid for subscript, `a[i] += foo()` means `a` type depend on `foo` return type and previous a types too. """ args = (self.naming[get_variable(node.target).id], ...
python
def visit_AugAssign(self, node): """ AugAssigned value depend on r-value type dependencies. It is valid for subscript, `a[i] += foo()` means `a` type depend on `foo` return type and previous a types too. """ args = (self.naming[get_variable(node.target).id], ...
[ "def", "visit_AugAssign", "(", "self", ",", "node", ")", ":", "args", "=", "(", "self", ".", "naming", "[", "get_variable", "(", "node", ".", "target", ")", ".", "id", "]", ",", "self", ".", "visit", "(", "node", ".", "value", ")", ")", "merge_dep"...
AugAssigned value depend on r-value type dependencies. It is valid for subscript, `a[i] += foo()` means `a` type depend on `foo` return type and previous a types too.
[ "AugAssigned", "value", "depend", "on", "r", "-", "value", "type", "dependencies", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L344-L355
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_For
def visit_For(self, node): """ Handle iterator variable in for loops. Iterate variable may be the correct one at the end of the loop. """ body = node.body if node.target.id in self.naming: body = [ast.Assign(targets=[node.target], value=node.iter)] + body ...
python
def visit_For(self, node): """ Handle iterator variable in for loops. Iterate variable may be the correct one at the end of the loop. """ body = node.body if node.target.id in self.naming: body = [ast.Assign(targets=[node.target], value=node.iter)] + body ...
[ "def", "visit_For", "(", "self", ",", "node", ")", ":", "body", "=", "node", ".", "body", "if", "node", ".", "target", ".", "id", "in", "self", ".", "naming", ":", "body", "=", "[", "ast", ".", "Assign", "(", "targets", "=", "[", "node", ".", "...
Handle iterator variable in for loops. Iterate variable may be the correct one at the end of the loop.
[ "Handle", "iterator", "variable", "in", "for", "loops", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L357-L370
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_BoolOp
def visit_BoolOp(self, node): """ Return type may come from any boolop operand. """ return sum((self.visit(value) for value in node.values), [])
python
def visit_BoolOp(self, node): """ Return type may come from any boolop operand. """ return sum((self.visit(value) for value in node.values), [])
[ "def", "visit_BoolOp", "(", "self", ",", "node", ")", ":", "return", "sum", "(", "(", "self", ".", "visit", "(", "value", ")", "for", "value", "in", "node", ".", "values", ")", ",", "[", "]", ")" ]
Return type may come from any boolop operand.
[ "Return", "type", "may", "come", "from", "any", "boolop", "operand", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L372-L374
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_BinOp
def visit_BinOp(self, node): """ Return type depend from both operand of the binary operation. """ args = [self.visit(arg) for arg in (node.left, node.right)] return list({frozenset.union(*x) for x in itertools.product(*args)})
python
def visit_BinOp(self, node): """ Return type depend from both operand of the binary operation. """ args = [self.visit(arg) for arg in (node.left, node.right)] return list({frozenset.union(*x) for x in itertools.product(*args)})
[ "def", "visit_BinOp", "(", "self", ",", "node", ")", ":", "args", "=", "[", "self", ".", "visit", "(", "arg", ")", "for", "arg", "in", "(", "node", ".", "left", ",", "node", ".", "right", ")", "]", "return", "list", "(", "{", "frozenset", ".", ...
Return type depend from both operand of the binary operation.
[ "Return", "type", "depend", "from", "both", "operand", "of", "the", "binary", "operation", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L376-L379
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_Call
def visit_Call(self, node): """ Function call depend on all function use in the call. >> a = foo(bar(c) or foobar(d)) Return type depend on [foo, bar] or [foo, foobar] """ args = [self.visit(arg) for arg in node.args] func = self.visit(node.func) params ...
python
def visit_Call(self, node): """ Function call depend on all function use in the call. >> a = foo(bar(c) or foobar(d)) Return type depend on [foo, bar] or [foo, foobar] """ args = [self.visit(arg) for arg in node.args] func = self.visit(node.func) params ...
[ "def", "visit_Call", "(", "self", ",", "node", ")", ":", "args", "=", "[", "self", ".", "visit", "(", "arg", ")", "for", "arg", "in", "node", ".", "args", "]", "func", "=", "self", ".", "visit", "(", "node", ".", "func", ")", "params", "=", "ar...
Function call depend on all function use in the call. >> a = foo(bar(c) or foobar(d)) Return type depend on [foo, bar] or [foo, foobar]
[ "Function", "call", "depend", "on", "all", "function", "use", "in", "the", "call", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L399-L410
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_Name
def visit_Name(self, node): """ Return dependencies for given variable. It have to be register first. """ if node.id in self.naming: return self.naming[node.id] elif node.id in self.global_declarations: return [frozenset([self.global_declarations[...
python
def visit_Name(self, node): """ Return dependencies for given variable. It have to be register first. """ if node.id in self.naming: return self.naming[node.id] elif node.id in self.global_declarations: return [frozenset([self.global_declarations[...
[ "def", "visit_Name", "(", "self", ",", "node", ")", ":", "if", "node", ".", "id", "in", "self", ".", "naming", ":", "return", "self", ".", "naming", "[", "node", ".", "id", "]", "elif", "node", ".", "id", "in", "self", ".", "global_declarations", "...
Return dependencies for given variable. It have to be register first.
[ "Return", "dependencies", "for", "given", "variable", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L435-L451
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_List
def visit_List(self, node): """ List construction depend on each elements type dependency. """ if node.elts: return list(set(sum([self.visit(elt) for elt in node.elts], []))) else: return [frozenset()]
python
def visit_List(self, node): """ List construction depend on each elements type dependency. """ if node.elts: return list(set(sum([self.visit(elt) for elt in node.elts], []))) else: return [frozenset()]
[ "def", "visit_List", "(", "self", ",", "node", ")", ":", "if", "node", ".", "elts", ":", "return", "list", "(", "set", "(", "sum", "(", "[", "self", ".", "visit", "(", "elt", ")", "for", "elt", "in", "node", ".", "elts", "]", ",", "[", "]", "...
List construction depend on each elements type dependency.
[ "List", "construction", "depend", "on", "each", "elements", "type", "dependency", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L453-L458
train
serge-sans-paille/pythran
pythran/types/type_dependencies.py
TypeDependencies.visit_ExceptHandler
def visit_ExceptHandler(self, node): """ Exception may declare a new variable. """ if node.name: self.naming[node.name.id] = [frozenset()] for stmt in node.body: self.visit(stmt)
python
def visit_ExceptHandler(self, node): """ Exception may declare a new variable. """ if node.name: self.naming[node.name.id] = [frozenset()] for stmt in node.body: self.visit(stmt)
[ "def", "visit_ExceptHandler", "(", "self", ",", "node", ")", ":", "if", "node", ".", "name", ":", "self", ".", "naming", "[", "node", ".", "name", ".", "id", "]", "=", "[", "frozenset", "(", ")", "]", "for", "stmt", "in", "node", ".", "body", ":"...
Exception may declare a new variable.
[ "Exception", "may", "declare", "a", "new", "variable", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/type_dependencies.py#L490-L495
train
serge-sans-paille/pythran
docs/papers/iop2014/xp/numba/arc_distance.py
arc_distance
def arc_distance(theta_1, phi_1, theta_2, phi_2): """ Calculates the pairwise arc distance between all points in vector a and b. """ temp = np.sin((theta_2-theta_1)/2)**2+np.cos(theta_1)*np.cos(theta_2)*np.sin((phi_2-phi_1)/2)**2 distance_matrix = 2 * (np.arctan2(np.sqrt(temp)...
python
def arc_distance(theta_1, phi_1, theta_2, phi_2): """ Calculates the pairwise arc distance between all points in vector a and b. """ temp = np.sin((theta_2-theta_1)/2)**2+np.cos(theta_1)*np.cos(theta_2)*np.sin((phi_2-phi_1)/2)**2 distance_matrix = 2 * (np.arctan2(np.sqrt(temp)...
[ "def", "arc_distance", "(", "theta_1", ",", "phi_1", ",", "theta_2", ",", "phi_2", ")", ":", "temp", "=", "np", ".", "sin", "(", "(", "theta_2", "-", "theta_1", ")", "/", "2", ")", "**", "2", "+", "np", ".", "cos", "(", "theta_1", ")", "*", "np...
Calculates the pairwise arc distance between all points in vector a and b.
[ "Calculates", "the", "pairwise", "arc", "distance", "between", "all", "points", "in", "vector", "a", "and", "b", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/docs/papers/iop2014/xp/numba/arc_distance.py#L5-L12
train
serge-sans-paille/pythran
pythran/transformations/expand_globals.py
ExpandGlobals.visit_Module
def visit_Module(self, node): """Turn globals assignment to functionDef and visit function defs. """ module_body = list() symbols = set() # Gather top level assigned variables. for stmt in node.body: if isinstance(stmt, (ast.Import, ast.ImportFrom)): f...
python
def visit_Module(self, node): """Turn globals assignment to functionDef and visit function defs. """ module_body = list() symbols = set() # Gather top level assigned variables. for stmt in node.body: if isinstance(stmt, (ast.Import, ast.ImportFrom)): f...
[ "def", "visit_Module", "(", "self", ",", "node", ")", ":", "module_body", "=", "list", "(", ")", "symbols", "=", "set", "(", ")", "for", "stmt", "in", "node", ".", "body", ":", "if", "isinstance", "(", "stmt", ",", "(", "ast", ".", "Import", ",", ...
Turn globals assignment to functionDef and visit function defs.
[ "Turn", "globals", "assignment", "to", "functionDef", "and", "visit", "function", "defs", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/expand_globals.py#L41-L104
train
serge-sans-paille/pythran
pythran/transformations/expand_globals.py
ExpandGlobals.visit_Name
def visit_Name(self, node): """ Turn global variable used not shadows to function call. We check it is a name from an assignment as import or functions use should not be turn into call. """ if (isinstance(node.ctx, ast.Load) and node.id not in self.local_...
python
def visit_Name(self, node): """ Turn global variable used not shadows to function call. We check it is a name from an assignment as import or functions use should not be turn into call. """ if (isinstance(node.ctx, ast.Load) and node.id not in self.local_...
[ "def", "visit_Name", "(", "self", ",", "node", ")", ":", "if", "(", "isinstance", "(", "node", ".", "ctx", ",", "ast", ".", "Load", ")", "and", "node", ".", "id", "not", "in", "self", ".", "local_decl", "and", "node", ".", "id", "in", "self", "."...
Turn global variable used not shadows to function call. We check it is a name from an assignment as import or functions use should not be turn into call.
[ "Turn", "global", "variable", "used", "not", "shadows", "to", "function", "call", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/expand_globals.py#L106-L119
train
serge-sans-paille/pythran
pythran/transformations/normalize_method_calls.py
NormalizeMethodCalls.visit_Module
def visit_Module(self, node): """ When we normalize call, we need to add correct import for method to function transformation. a.max() for numpy array will become: numpy.max(a) so we have to import numpy. """ self.skip_f...
python
def visit_Module(self, node): """ When we normalize call, we need to add correct import for method to function transformation. a.max() for numpy array will become: numpy.max(a) so we have to import numpy. """ self.skip_f...
[ "def", "visit_Module", "(", "self", ",", "node", ")", ":", "self", ".", "skip_functions", "=", "True", "self", ".", "generic_visit", "(", "node", ")", "self", ".", "skip_functions", "=", "False", "self", ".", "generic_visit", "(", "node", ")", "new_imports...
When we normalize call, we need to add correct import for method to function transformation. a.max() for numpy array will become: numpy.max(a) so we have to import numpy.
[ "When", "we", "normalize", "call", "we", "need", "to", "add", "correct", "import", "for", "method", "to", "function", "transformation", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/normalize_method_calls.py#L31-L53
train
serge-sans-paille/pythran
pythran/transformations/normalize_method_calls.py
NormalizeMethodCalls.renamer
def renamer(v, cur_module): """ Rename function path to fit Pythonic naming. """ mname = demangle(v) name = v + '_' if name in cur_module: return name, mname else: return v, mname
python
def renamer(v, cur_module): """ Rename function path to fit Pythonic naming. """ mname = demangle(v) name = v + '_' if name in cur_module: return name, mname else: return v, mname
[ "def", "renamer", "(", "v", ",", "cur_module", ")", ":", "mname", "=", "demangle", "(", "v", ")", "name", "=", "v", "+", "'_'", "if", "name", "in", "cur_module", ":", "return", "name", ",", "mname", "else", ":", "return", "v", ",", "mname" ]
Rename function path to fit Pythonic naming.
[ "Rename", "function", "path", "to", "fit", "Pythonic", "naming", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/normalize_method_calls.py#L139-L149
train
serge-sans-paille/pythran
pythran/transformations/normalize_method_calls.py
NormalizeMethodCalls.visit_Call
def visit_Call(self, node): """ Transform call site to have normal function call. Examples -------- For methods: >> a = [1, 2, 3] >> a.append(1) Becomes >> __list__.append(a, 1) For functions: >> __builtin__.dict.fromkeys([1, ...
python
def visit_Call(self, node): """ Transform call site to have normal function call. Examples -------- For methods: >> a = [1, 2, 3] >> a.append(1) Becomes >> __list__.append(a, 1) For functions: >> __builtin__.dict.fromkeys([1, ...
[ "def", "visit_Call", "(", "self", ",", "node", ")", ":", "node", "=", "self", ".", "generic_visit", "(", "node", ")", "if", "isinstance", "(", "node", ".", "func", ",", "ast", ".", "Attribute", ")", ":", "if", "node", ".", "func", ".", "attr", "in"...
Transform call site to have normal function call. Examples -------- For methods: >> a = [1, 2, 3] >> a.append(1) Becomes >> __list__.append(a, 1) For functions: >> __builtin__.dict.fromkeys([1, 2, 3]) Becomes >> __builtin__....
[ "Transform", "call", "site", "to", "have", "normal", "function", "call", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/normalize_method_calls.py#L151-L231
train
serge-sans-paille/pythran
pythran/toolchain.py
_extract_specs_dependencies
def _extract_specs_dependencies(specs): """ Extract types dependencies from specs for each exported signature. """ deps = set() # for each function for signatures in specs.functions.values(): # for each signature for signature in signatures: # for each argument fo...
python
def _extract_specs_dependencies(specs): """ Extract types dependencies from specs for each exported signature. """ deps = set() # for each function for signatures in specs.functions.values(): # for each signature for signature in signatures: # for each argument fo...
[ "def", "_extract_specs_dependencies", "(", "specs", ")", ":", "deps", "=", "set", "(", ")", "for", "signatures", "in", "specs", ".", "functions", ".", "values", "(", ")", ":", "for", "signature", "in", "signatures", ":", "for", "t", "in", "signature", ":...
Extract types dependencies from specs for each exported signature.
[ "Extract", "types", "dependencies", "from", "specs", "for", "each", "exported", "signature", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/toolchain.py#L49-L65
train
serge-sans-paille/pythran
pythran/toolchain.py
_parse_optimization
def _parse_optimization(optimization): '''Turns an optimization of the form my_optim my_package.my_optim into the associated symbol''' splitted = optimization.split('.') if len(splitted) == 1: splitted = ['pythran', 'optimizations'] + splitted return reduce(getattr, split...
python
def _parse_optimization(optimization): '''Turns an optimization of the form my_optim my_package.my_optim into the associated symbol''' splitted = optimization.split('.') if len(splitted) == 1: splitted = ['pythran', 'optimizations'] + splitted return reduce(getattr, split...
[ "def", "_parse_optimization", "(", "optimization", ")", ":", "splitted", "=", "optimization", ".", "split", "(", "'.'", ")", "if", "len", "(", "splitted", ")", "==", "1", ":", "splitted", "=", "[", "'pythran'", ",", "'optimizations'", "]", "+", "splitted",...
Turns an optimization of the form my_optim my_package.my_optim into the associated symbol
[ "Turns", "an", "optimization", "of", "the", "form", "my_optim", "my_package", ".", "my_optim", "into", "the", "associated", "symbol" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/toolchain.py#L68-L76
train
serge-sans-paille/pythran
pythran/toolchain.py
_write_temp
def _write_temp(content, suffix): '''write `content` to a temporary XXX`suffix` file and return the filename. It is user's responsibility to delete when done.''' with NamedTemporaryFile(mode='w', suffix=suffix, delete=False) as out: out.write(content) return out.name
python
def _write_temp(content, suffix): '''write `content` to a temporary XXX`suffix` file and return the filename. It is user's responsibility to delete when done.''' with NamedTemporaryFile(mode='w', suffix=suffix, delete=False) as out: out.write(content) return out.name
[ "def", "_write_temp", "(", "content", ",", "suffix", ")", ":", "with", "NamedTemporaryFile", "(", "mode", "=", "'w'", ",", "suffix", "=", "suffix", ",", "delete", "=", "False", ")", "as", "out", ":", "out", ".", "write", "(", "content", ")", "return", ...
write `content` to a temporary XXX`suffix` file and return the filename. It is user's responsibility to delete when done.
[ "write", "content", "to", "a", "temporary", "XXX", "suffix", "file", "and", "return", "the", "filename", ".", "It", "is", "user", "s", "responsibility", "to", "delete", "when", "done", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/toolchain.py#L79-L84
train
serge-sans-paille/pythran
pythran/toolchain.py
front_middle_end
def front_middle_end(module_name, code, optimizations=None, module_dir=None): """Front-end and middle-end compilation steps""" pm = PassManager(module_name, module_dir) # front end ir, renamings, docstrings = frontend.parse(pm, code) # middle-end if optimizations is None: optimizations...
python
def front_middle_end(module_name, code, optimizations=None, module_dir=None): """Front-end and middle-end compilation steps""" pm = PassManager(module_name, module_dir) # front end ir, renamings, docstrings = frontend.parse(pm, code) # middle-end if optimizations is None: optimizations...
[ "def", "front_middle_end", "(", "module_name", ",", "code", ",", "optimizations", "=", "None", ",", "module_dir", "=", "None", ")", ":", "pm", "=", "PassManager", "(", "module_name", ",", "module_dir", ")", "ir", ",", "renamings", ",", "docstrings", "=", "...
Front-end and middle-end compilation steps
[ "Front", "-", "end", "and", "middle", "-", "end", "compilation", "steps" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/toolchain.py#L99-L112
train
serge-sans-paille/pythran
pythran/toolchain.py
generate_py
def generate_py(module_name, code, optimizations=None, module_dir=None): '''python + pythran spec -> py code Prints and returns the optimized python code. ''' pm, ir, _, _ = front_middle_end(module_name, code, optimizations, module_dir) return pm.dump(Python, ...
python
def generate_py(module_name, code, optimizations=None, module_dir=None): '''python + pythran spec -> py code Prints and returns the optimized python code. ''' pm, ir, _, _ = front_middle_end(module_name, code, optimizations, module_dir) return pm.dump(Python, ...
[ "def", "generate_py", "(", "module_name", ",", "code", ",", "optimizations", "=", "None", ",", "module_dir", "=", "None", ")", ":", "pm", ",", "ir", ",", "_", ",", "_", "=", "front_middle_end", "(", "module_name", ",", "code", ",", "optimizations", ",", ...
python + pythran spec -> py code Prints and returns the optimized python code.
[ "python", "+", "pythran", "spec", "-", ">", "py", "code" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/toolchain.py#L118-L128
train
serge-sans-paille/pythran
pythran/toolchain.py
compile_cxxfile
def compile_cxxfile(module_name, cxxfile, output_binary=None, **kwargs): '''c++ file -> native module Return the filename of the produced shared library Raises CompileError on failure ''' builddir = mkdtemp() buildtmp = mkdtemp() extension_args = make_extension(python=True, **kwargs) ...
python
def compile_cxxfile(module_name, cxxfile, output_binary=None, **kwargs): '''c++ file -> native module Return the filename of the produced shared library Raises CompileError on failure ''' builddir = mkdtemp() buildtmp = mkdtemp() extension_args = make_extension(python=True, **kwargs) ...
[ "def", "compile_cxxfile", "(", "module_name", ",", "cxxfile", ",", "output_binary", "=", "None", ",", "**", "kwargs", ")", ":", "builddir", "=", "mkdtemp", "(", ")", "buildtmp", "=", "mkdtemp", "(", ")", "extension_args", "=", "make_extension", "(", "python"...
c++ file -> native module Return the filename of the produced shared library Raises CompileError on failure
[ "c", "++", "file", "-", ">", "native", "module", "Return", "the", "filename", "of", "the", "produced", "shared", "library", "Raises", "CompileError", "on", "failure" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/toolchain.py#L288-L345
train
serge-sans-paille/pythran
pythran/toolchain.py
compile_pythranfile
def compile_pythranfile(file_path, output_file=None, module_name=None, cpponly=False, pyonly=False, **kwargs): """ Pythran file -> c++ file -> native module. Returns the generated .so (or .cpp if `cpponly` is set to true). Usage without an existing spec file >>> with open(...
python
def compile_pythranfile(file_path, output_file=None, module_name=None, cpponly=False, pyonly=False, **kwargs): """ Pythran file -> c++ file -> native module. Returns the generated .so (or .cpp if `cpponly` is set to true). Usage without an existing spec file >>> with open(...
[ "def", "compile_pythranfile", "(", "file_path", ",", "output_file", "=", "None", ",", "module_name", "=", "None", ",", "cpponly", "=", "False", ",", "pyonly", "=", "False", ",", "**", "kwargs", ")", ":", "if", "not", "output_file", ":", "_", ",", "basena...
Pythran file -> c++ file -> native module. Returns the generated .so (or .cpp if `cpponly` is set to true). Usage without an existing spec file >>> with open('pythran_test.py', 'w') as fd: ... _ = fd.write('def foo(i): return i ** 2') >>> cpp_path = compile_pythranfile('pythran_test.py', cppon...
[ "Pythran", "file", "-", ">", "c", "++", "file", "-", ">", "native", "module", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/toolchain.py#L425-L474
train
serge-sans-paille/pythran
pythran/transformations/remove_comprehension.py
RemoveComprehension.nest_reducer
def nest_reducer(x, g): """ Create a ast.For node from a comprehension and another node. g is an ast.comprehension. x is the code that have to be executed. Examples -------- >> [i for i in xrange(2)] Becomes >> for i in xrange(2): >> ...
python
def nest_reducer(x, g): """ Create a ast.For node from a comprehension and another node. g is an ast.comprehension. x is the code that have to be executed. Examples -------- >> [i for i in xrange(2)] Becomes >> for i in xrange(2): >> ...
[ "def", "nest_reducer", "(", "x", ",", "g", ")", ":", "def", "wrap_in_ifs", "(", "node", ",", "ifs", ")", ":", "return", "reduce", "(", "lambda", "n", ",", "if_", ":", "ast", ".", "If", "(", "if_", ",", "[", "n", "]", ",", "[", "]", ")", ",", ...
Create a ast.For node from a comprehension and another node. g is an ast.comprehension. x is the code that have to be executed. Examples -------- >> [i for i in xrange(2)] Becomes >> for i in xrange(2): >> ... x code with if clauses ... It ...
[ "Create", "a", "ast", ".", "For", "node", "from", "a", "comprehension", "and", "another", "node", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/remove_comprehension.py#L34-L72
train
serge-sans-paille/pythran
pythran/cxxgen.py
Declarator.inline
def inline(self): """Return the declarator as a single line.""" tp_lines, tp_decl = self.get_decl_pair() tp_lines = " ".join(tp_lines) if tp_decl is None: return tp_lines else: return "%s %s" % (tp_lines, tp_decl)
python
def inline(self): """Return the declarator as a single line.""" tp_lines, tp_decl = self.get_decl_pair() tp_lines = " ".join(tp_lines) if tp_decl is None: return tp_lines else: return "%s %s" % (tp_lines, tp_decl)
[ "def", "inline", "(", "self", ")", ":", "tp_lines", ",", "tp_decl", "=", "self", ".", "get_decl_pair", "(", ")", "tp_lines", "=", "\" \"", ".", "join", "(", "tp_lines", ")", "if", "tp_decl", "is", "None", ":", "return", "tp_lines", "else", ":", "return...
Return the declarator as a single line.
[ "Return", "the", "declarator", "as", "a", "single", "line", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/cxxgen.py#L66-L73
train
serge-sans-paille/pythran
pythran/cxxgen.py
Struct.get_decl_pair
def get_decl_pair(self): """ See Declarator.get_decl_pair.""" def get_tp(): """ Iterator generating lines for struct definition. """ decl = "struct " if self.tpname is not None: decl += self.tpname if self.inherit is not None: ...
python
def get_decl_pair(self): """ See Declarator.get_decl_pair.""" def get_tp(): """ Iterator generating lines for struct definition. """ decl = "struct " if self.tpname is not None: decl += self.tpname if self.inherit is not None: ...
[ "def", "get_decl_pair", "(", "self", ")", ":", "def", "get_tp", "(", ")", ":", "decl", "=", "\"struct \"", "if", "self", ".", "tpname", "is", "not", "None", ":", "decl", "+=", "self", ".", "tpname", "if", "self", ".", "inherit", "is", "not", "None", ...
See Declarator.get_decl_pair.
[ "See", "Declarator", ".", "get_decl_pair", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/cxxgen.py#L160-L175
train
serge-sans-paille/pythran
pythran/transformations/normalize_static_if.py
NormalizeStaticIf.make_control_flow_handlers
def make_control_flow_handlers(self, cont_n, status_n, expected_return, has_cont, has_break): ''' Create the statements in charge of gathering control flow information for the static_if result, and executes the expected control flow instruction ...
python
def make_control_flow_handlers(self, cont_n, status_n, expected_return, has_cont, has_break): ''' Create the statements in charge of gathering control flow information for the static_if result, and executes the expected control flow instruction ...
[ "def", "make_control_flow_handlers", "(", "self", ",", "cont_n", ",", "status_n", ",", "expected_return", ",", "has_cont", ",", "has_break", ")", ":", "if", "expected_return", ":", "assign", "=", "cont_ass", "=", "[", "ast", ".", "Assign", "(", "[", "ast", ...
Create the statements in charge of gathering control flow information for the static_if result, and executes the expected control flow instruction
[ "Create", "the", "statements", "in", "charge", "of", "gathering", "control", "flow", "information", "for", "the", "static_if", "result", "and", "executes", "the", "expected", "control", "flow", "instruction" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/normalize_static_if.py#L184-L210
train
serge-sans-paille/pythran
pythran/optimizations/pattern_transform.py
PlaceholderReplace.visit
def visit(self, node): """ Replace the placeholder if it is one or continue. """ if isinstance(node, Placeholder): return self.placeholders[node.id] else: return super(PlaceholderReplace, self).visit(node)
python
def visit(self, node): """ Replace the placeholder if it is one or continue. """ if isinstance(node, Placeholder): return self.placeholders[node.id] else: return super(PlaceholderReplace, self).visit(node)
[ "def", "visit", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "Placeholder", ")", ":", "return", "self", ".", "placeholders", "[", "node", ".", "id", "]", "else", ":", "return", "super", "(", "PlaceholderReplace", ",", "self...
Replace the placeholder if it is one or continue.
[ "Replace", "the", "placeholder", "if", "it", "is", "one", "or", "continue", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/pattern_transform.py#L149-L154
train
serge-sans-paille/pythran
pythran/optimizations/pattern_transform.py
PatternTransform.visit
def visit(self, node): """ Try to replace if node match the given pattern or keep going. """ for pattern, replace in know_pattern: check = Check(node, dict()) if check.visit(pattern): node = PlaceholderReplace(check.placeholders).visit(replace()) s...
python
def visit(self, node): """ Try to replace if node match the given pattern or keep going. """ for pattern, replace in know_pattern: check = Check(node, dict()) if check.visit(pattern): node = PlaceholderReplace(check.placeholders).visit(replace()) s...
[ "def", "visit", "(", "self", ",", "node", ")", ":", "for", "pattern", ",", "replace", "in", "know_pattern", ":", "check", "=", "Check", "(", "node", ",", "dict", "(", ")", ")", "if", "check", ".", "visit", "(", "pattern", ")", ":", "node", "=", "...
Try to replace if node match the given pattern or keep going.
[ "Try", "to", "replace", "if", "node", "match", "the", "given", "pattern", "or", "keep", "going", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/pattern_transform.py#L169-L176
train
serge-sans-paille/pythran
pythran/analyses/local_declarations.py
LocalNameDeclarations.visit_Name
def visit_Name(self, node): """ Any node with Store or Param context is a new identifier. """ if isinstance(node.ctx, (ast.Store, ast.Param)): self.result.add(node.id)
python
def visit_Name(self, node): """ Any node with Store or Param context is a new identifier. """ if isinstance(node.ctx, (ast.Store, ast.Param)): self.result.add(node.id)
[ "def", "visit_Name", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ".", "ctx", ",", "(", "ast", ".", "Store", ",", "ast", ".", "Param", ")", ")", ":", "self", ".", "result", ".", "add", "(", "node", ".", "id", ")" ]
Any node with Store or Param context is a new identifier.
[ "Any", "node", "with", "Store", "or", "Param", "context", "is", "a", "new", "identifier", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/local_declarations.py#L66-L69
train
serge-sans-paille/pythran
pythran/analyses/local_declarations.py
LocalNameDeclarations.visit_FunctionDef
def visit_FunctionDef(self, node): """ Function name is a possible identifier. """ self.result.add(node.name) self.generic_visit(node)
python
def visit_FunctionDef(self, node): """ Function name is a possible identifier. """ self.result.add(node.name) self.generic_visit(node)
[ "def", "visit_FunctionDef", "(", "self", ",", "node", ")", ":", "self", ".", "result", ".", "add", "(", "node", ".", "name", ")", "self", ".", "generic_visit", "(", "node", ")" ]
Function name is a possible identifier.
[ "Function", "name", "is", "a", "possible", "identifier", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/local_declarations.py#L71-L74
train
serge-sans-paille/pythran
pythran/analyses/cfg.py
CFG.visit_If
def visit_If(self, node): """ OUT = true branch U false branch RAISES = true branch U false branch """ currs = (node,) raises = () # true branch for n in node.body: self.result.add_node(n) for curr in currs: self.re...
python
def visit_If(self, node): """ OUT = true branch U false branch RAISES = true branch U false branch """ currs = (node,) raises = () # true branch for n in node.body: self.result.add_node(n) for curr in currs: self.re...
[ "def", "visit_If", "(", "self", ",", "node", ")", ":", "currs", "=", "(", "node", ",", ")", "raises", "=", "(", ")", "for", "n", "in", "node", ".", "body", ":", "self", ".", "result", ".", "add_node", "(", "n", ")", "for", "curr", "in", "currs"...
OUT = true branch U false branch RAISES = true branch U false branch
[ "OUT", "=", "true", "branch", "U", "false", "branch", "RAISES", "=", "true", "branch", "U", "false", "branch" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/cfg.py#L104-L131
train
serge-sans-paille/pythran
pythran/analyses/cfg.py
CFG.visit_Try
def visit_Try(self, node): """ OUT = body's U handler's RAISES = handler's this equation is not has good has it could be... but we need type information to be more accurate """ currs = (node,) raises = () for handler in node.handlers: s...
python
def visit_Try(self, node): """ OUT = body's U handler's RAISES = handler's this equation is not has good has it could be... but we need type information to be more accurate """ currs = (node,) raises = () for handler in node.handlers: s...
[ "def", "visit_Try", "(", "self", ",", "node", ")", ":", "currs", "=", "(", "node", ",", ")", "raises", "=", "(", ")", "for", "handler", "in", "node", ".", "handlers", ":", "self", ".", "result", ".", "add_node", "(", "handler", ")", "for", "n", "...
OUT = body's U handler's RAISES = handler's this equation is not has good has it could be... but we need type information to be more accurate
[ "OUT", "=", "body", "s", "U", "handler", "s", "RAISES", "=", "handler", "s", "this", "equation", "is", "not", "has", "good", "has", "it", "could", "be", "...", "but", "we", "need", "type", "information", "to", "be", "more", "accurate" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/cfg.py#L143-L169
train
serge-sans-paille/pythran
pythran/analyses/cfg.py
CFG.visit_ExceptHandler
def visit_ExceptHandler(self, node): """OUT = body's, RAISES = body's""" currs = (node,) raises = () for n in node.body: self.result.add_node(n) for curr in currs: self.result.add_edge(curr, n) currs, nraises = self.visit(n) ...
python
def visit_ExceptHandler(self, node): """OUT = body's, RAISES = body's""" currs = (node,) raises = () for n in node.body: self.result.add_node(n) for curr in currs: self.result.add_edge(curr, n) currs, nraises = self.visit(n) ...
[ "def", "visit_ExceptHandler", "(", "self", ",", "node", ")", ":", "currs", "=", "(", "node", ",", ")", "raises", "=", "(", ")", "for", "n", "in", "node", ".", "body", ":", "self", ".", "result", ".", "add_node", "(", "n", ")", "for", "curr", "in"...
OUT = body's, RAISES = body's
[ "OUT", "=", "body", "s", "RAISES", "=", "body", "s" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/cfg.py#L171-L181
train
serge-sans-paille/pythran
pythran/analyses/is_assigned.py
IsAssigned.visit_Name
def visit_Name(self, node): """ Stored variable have new value. """ if isinstance(node.ctx, ast.Store): self.result[node.id] = True
python
def visit_Name(self, node): """ Stored variable have new value. """ if isinstance(node.ctx, ast.Store): self.result[node.id] = True
[ "def", "visit_Name", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ".", "ctx", ",", "ast", ".", "Store", ")", ":", "self", ".", "result", "[", "node", ".", "id", "]", "=", "True" ]
Stored variable have new value.
[ "Stored", "variable", "have", "new", "value", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/is_assigned.py#L23-L26
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.add
def add(self, variable, range_): """ Add a new low and high bound for a variable. As it is flow insensitive, it compares it with old values and update it if needed. """ if variable not in self.result: self.result[variable] = range_ else: s...
python
def add(self, variable, range_): """ Add a new low and high bound for a variable. As it is flow insensitive, it compares it with old values and update it if needed. """ if variable not in self.result: self.result[variable] = range_ else: s...
[ "def", "add", "(", "self", ",", "variable", ",", "range_", ")", ":", "if", "variable", "not", "in", "self", ".", "result", ":", "self", ".", "result", "[", "variable", "]", "=", "range_", "else", ":", "self", ".", "result", "[", "variable", "]", "=...
Add a new low and high bound for a variable. As it is flow insensitive, it compares it with old values and update it if needed.
[ "Add", "a", "new", "low", "and", "high", "bound", "for", "a", "variable", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L47-L58
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_Assign
def visit_Assign(self, node): """ Set range value for assigned variable. We do not handle container values. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(): a = b = 2") >>> pm = passmanager.PassManager("test") ...
python
def visit_Assign(self, node): """ Set range value for assigned variable. We do not handle container values. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(): a = b = 2") >>> pm = passmanager.PassManager("test") ...
[ "def", "visit_Assign", "(", "self", ",", "node", ")", ":", "assigned_range", "=", "self", ".", "visit", "(", "node", ".", "value", ")", "for", "target", "in", "node", ".", "targets", ":", "if", "isinstance", "(", "target", ",", "ast", ".", "Name", ")...
Set range value for assigned variable. We do not handle container values. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(): a = b = 2") >>> pm = passmanager.PassManager("test") >>> res = pm.gather(RangeValues, node) ...
[ "Set", "range", "value", "for", "assigned", "variable", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L74-L96
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_AugAssign
def visit_AugAssign(self, node): """ Update range value for augassigned variables. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(): a = 2; a -= 1") >>> pm = passmanager.PassManager("test") >>> res = pm.gather(RangeValue...
python
def visit_AugAssign(self, node): """ Update range value for augassigned variables. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(): a = 2; a -= 1") >>> pm = passmanager.PassManager("test") >>> res = pm.gather(RangeValue...
[ "def", "visit_AugAssign", "(", "self", ",", "node", ")", ":", "self", ".", "generic_visit", "(", "node", ")", "if", "isinstance", "(", "node", ".", "target", ",", "ast", ".", "Name", ")", ":", "name", "=", "node", ".", "target", ".", "id", "res", "...
Update range value for augassigned variables. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(): a = 2; a -= 1") >>> pm = passmanager.PassManager("test") >>> res = pm.gather(RangeValues, node) >>> res['a'] Interva...
[ "Update", "range", "value", "for", "augassigned", "variables", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L98-L115
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_For
def visit_For(self, node): """ Handle iterate variable in for loops. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = b = c = 2 ... for i in __builtin__.range(1): ... a -= ...
python
def visit_For(self, node): """ Handle iterate variable in for loops. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = b = c = 2 ... for i in __builtin__.range(1): ... a -= ...
[ "def", "visit_For", "(", "self", ",", "node", ")", ":", "assert", "isinstance", "(", "node", ".", "target", ",", "ast", ".", "Name", ")", ",", "\"For apply on variables.\"", "self", ".", "visit", "(", "node", ".", "iter", ")", "if", "isinstance", "(", ...
Handle iterate variable in for loops. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = b = c = 2 ... for i in __builtin__.range(1): ... a -= 1 ... b += 1''') ...
[ "Handle", "iterate", "variable", "in", "for", "loops", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L117-L146
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_loop
def visit_loop(self, node, cond=None): """ Handle incremented variables in loop body. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = b = c = 2 ... while a > 0: ... a -= 1...
python
def visit_loop(self, node, cond=None): """ Handle incremented variables in loop body. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = b = c = 2 ... while a > 0: ... a -= 1...
[ "def", "visit_loop", "(", "self", ",", "node", ",", "cond", "=", "None", ")", ":", "for", "stmt", "in", "node", ".", "body", ":", "self", ".", "visit", "(", "stmt", ")", "old_range", "=", "self", ".", "result", ".", "copy", "(", ")", "for", "stmt...
Handle incremented variables in loop body. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = b = c = 2 ... while a > 0: ... a -= 1 ... b += 1''') >>> pm = pa...
[ "Handle", "incremented", "variables", "in", "loop", "body", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L148-L189
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_BoolOp
def visit_BoolOp(self, node): """ Merge right and left operands ranges. TODO : We could exclude some operand with this range information... >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ...
python
def visit_BoolOp(self, node): """ Merge right and left operands ranges. TODO : We could exclude some operand with this range information... >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ...
[ "def", "visit_BoolOp", "(", "self", ",", "node", ")", ":", "res", "=", "list", "(", "zip", "(", "*", "[", "self", ".", "visit", "(", "elt", ")", ".", "bounds", "(", ")", "for", "elt", "in", "node", ".", "values", "]", ")", ")", "return", "self"...
Merge right and left operands ranges. TODO : We could exclude some operand with this range information... >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ... c = 3 ... d = ...
[ "Merge", "right", "and", "left", "operands", "ranges", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L195-L213
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_BinOp
def visit_BinOp(self, node): """ Combine operands ranges for given operator. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ... c = 3 ... d = a - c''') >>> pm = pas...
python
def visit_BinOp(self, node): """ Combine operands ranges for given operator. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ... c = 3 ... d = a - c''') >>> pm = pas...
[ "def", "visit_BinOp", "(", "self", ",", "node", ")", ":", "res", "=", "combine", "(", "node", ".", "op", ",", "self", ".", "visit", "(", "node", ".", "left", ")", ",", "self", ".", "visit", "(", "node", ".", "right", ")", ")", "return", "self", ...
Combine operands ranges for given operator. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ... c = 3 ... d = a - c''') >>> pm = passmanager.PassManager("test") >>> ...
[ "Combine", "operands", "ranges", "for", "given", "operator", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L215-L231
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_UnaryOp
def visit_UnaryOp(self, node): """ Update range with given unary operation. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ... c = -a ... d = ~a ... f = +a ...
python
def visit_UnaryOp(self, node): """ Update range with given unary operation. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ... c = -a ... d = ~a ... f = +a ...
[ "def", "visit_UnaryOp", "(", "self", ",", "node", ")", ":", "res", "=", "self", ".", "visit", "(", "node", ".", "operand", ")", "if", "isinstance", "(", "node", ".", "op", ",", "ast", ".", "Not", ")", ":", "res", "=", "Interval", "(", "0", ",", ...
Update range with given unary operation. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 ... c = -a ... d = ~a ... f = +a ... e = not a''') >>> pm = ...
[ "Update", "range", "with", "given", "unary", "operation", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L233-L269
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_If
def visit_If(self, node): """ Handle iterate variable across branches >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(a): ... if a > 1: b = 1 ... else: b = 3''') >>> pm = passmanager.PassMa...
python
def visit_If(self, node): """ Handle iterate variable across branches >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(a): ... if a > 1: b = 1 ... else: b = 3''') >>> pm = passmanager.PassMa...
[ "def", "visit_If", "(", "self", ",", "node", ")", ":", "self", ".", "visit", "(", "node", ".", "test", ")", "old_range", "=", "self", ".", "result", "self", ".", "result", "=", "old_range", ".", "copy", "(", ")", "for", "stmt", "in", "node", ".", ...
Handle iterate variable across branches >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(a): ... if a > 1: b = 1 ... else: b = 3''') >>> pm = passmanager.PassManager("test") >>> res = pm.gat...
[ "Handle", "iterate", "variable", "across", "branches" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L271-L304
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_IfExp
def visit_IfExp(self, node): """ Use worst case for both possible values. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 or 3 ... b = 4 or 5 ... c = a if a else b''') ...
python
def visit_IfExp(self, node): """ Use worst case for both possible values. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 or 3 ... b = 4 or 5 ... c = a if a else b''') ...
[ "def", "visit_IfExp", "(", "self", ",", "node", ")", ":", "self", ".", "visit", "(", "node", ".", "test", ")", "body_res", "=", "self", ".", "visit", "(", "node", ".", "body", ")", "orelse_res", "=", "self", ".", "visit", "(", "node", ".", "orelse"...
Use worst case for both possible values. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 or 3 ... b = 4 or 5 ... c = a if a else b''') >>> pm = passmanager.PassManager("test...
[ "Use", "worst", "case", "for", "both", "possible", "values", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L306-L324
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_Compare
def visit_Compare(self, node): """ Boolean are possible index. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 or 3 ... b = 4 or 5 ... c = a < b ... d = b < 3 ...
python
def visit_Compare(self, node): """ Boolean are possible index. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 or 3 ... b = 4 or 5 ... c = a < b ... d = b < 3 ...
[ "def", "visit_Compare", "(", "self", ",", "node", ")", ":", "if", "any", "(", "isinstance", "(", "op", ",", "(", "ast", ".", "In", ",", "ast", ".", "NotIn", ",", "ast", ".", "Is", ",", "ast", ".", "IsNot", ")", ")", "for", "op", "in", "node", ...
Boolean are possible index. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = 2 or 3 ... b = 4 or 5 ... c = a < b ... d = b < 3 ... e = b == 4''') >>> pm...
[ "Boolean", "are", "possible", "index", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L326-L368
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_Call
def visit_Call(self, node): """ Function calls are not handled for now. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = __builtin__.range(10)''') >>> pm = passmanager.PassManager("test") ...
python
def visit_Call(self, node): """ Function calls are not handled for now. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = __builtin__.range(10)''') >>> pm = passmanager.PassManager("test") ...
[ "def", "visit_Call", "(", "self", ",", "node", ")", ":", "for", "alias", "in", "self", ".", "aliases", "[", "node", ".", "func", "]", ":", "if", "alias", "is", "MODULES", "[", "'__builtin__'", "]", "[", "'getattr'", "]", ":", "attr_name", "=", "node"...
Function calls are not handled for now. >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse(''' ... def foo(): ... a = __builtin__.range(10)''') >>> pm = passmanager.PassManager("test") >>> res = pm.gather(RangeValues, nod...
[ "Function", "calls", "are", "not", "handled", "for", "now", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L370-L394
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_Num
def visit_Num(self, node): """ Handle literals integers values. """ if isinstance(node.n, int): return self.add(node, Interval(node.n, node.n)) return UNKNOWN_RANGE
python
def visit_Num(self, node): """ Handle literals integers values. """ if isinstance(node.n, int): return self.add(node, Interval(node.n, node.n)) return UNKNOWN_RANGE
[ "def", "visit_Num", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ".", "n", ",", "int", ")", ":", "return", "self", ".", "add", "(", "node", ",", "Interval", "(", "node", ".", "n", ",", "node", ".", "n", ")", ")", "return...
Handle literals integers values.
[ "Handle", "literals", "integers", "values", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L396-L400
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.visit_Name
def visit_Name(self, node): """ Get range for parameters for examples or false branching. """ return self.add(node, self.result[node.id])
python
def visit_Name(self, node): """ Get range for parameters for examples or false branching. """ return self.add(node, self.result[node.id])
[ "def", "visit_Name", "(", "self", ",", "node", ")", ":", "return", "self", ".", "add", "(", "node", ",", "self", ".", "result", "[", "node", ".", "id", "]", ")" ]
Get range for parameters for examples or false branching.
[ "Get", "range", "for", "parameters", "for", "examples", "or", "false", "branching", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L402-L404
train
serge-sans-paille/pythran
pythran/analyses/range_values.py
RangeValues.generic_visit
def generic_visit(self, node): """ Other nodes are not known and range value neither. """ super(RangeValues, self).generic_visit(node) return self.add(node, UNKNOWN_RANGE)
python
def generic_visit(self, node): """ Other nodes are not known and range value neither. """ super(RangeValues, self).generic_visit(node) return self.add(node, UNKNOWN_RANGE)
[ "def", "generic_visit", "(", "self", ",", "node", ")", ":", "super", "(", "RangeValues", ",", "self", ")", ".", "generic_visit", "(", "node", ")", "return", "self", ".", "add", "(", "node", ",", "UNKNOWN_RANGE", ")" ]
Other nodes are not known and range value neither.
[ "Other", "nodes", "are", "not", "known", "and", "range", "value", "neither", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/range_values.py#L448-L451
train
serge-sans-paille/pythran
pythran/run.py
compile_flags
def compile_flags(args): """ Build a dictionnary with an entry for cppflags, ldflags, and cxxflags. These options are filled according to the command line defined options """ compiler_options = { 'define_macros': args.defines, 'undef_macros': args.undefs, 'include_dirs': a...
python
def compile_flags(args): """ Build a dictionnary with an entry for cppflags, ldflags, and cxxflags. These options are filled according to the command line defined options """ compiler_options = { 'define_macros': args.defines, 'undef_macros': args.undefs, 'include_dirs': a...
[ "def", "compile_flags", "(", "args", ")", ":", "compiler_options", "=", "{", "'define_macros'", ":", "args", ".", "defines", ",", "'undef_macros'", ":", "args", ".", "undefs", ",", "'include_dirs'", ":", "args", ".", "include_dirs", ",", "'extra_compile_args'", ...
Build a dictionnary with an entry for cppflags, ldflags, and cxxflags. These options are filled according to the command line defined options
[ "Build", "a", "dictionnary", "with", "an", "entry", "for", "cppflags", "ldflags", "and", "cxxflags", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/run.py#L25-L46
train
serge-sans-paille/pythran
pythran/optimizations/iter_transformation.py
IterTransformation.find_matching_builtin
def find_matching_builtin(self, node): """ Return matched keyword. If the node alias on a correct keyword (and only it), it matches. """ for path in EQUIVALENT_ITERATORS.keys(): correct_alias = {path_to_node(path)} if self.aliases[node.func] == correct_al...
python
def find_matching_builtin(self, node): """ Return matched keyword. If the node alias on a correct keyword (and only it), it matches. """ for path in EQUIVALENT_ITERATORS.keys(): correct_alias = {path_to_node(path)} if self.aliases[node.func] == correct_al...
[ "def", "find_matching_builtin", "(", "self", ",", "node", ")", ":", "for", "path", "in", "EQUIVALENT_ITERATORS", ".", "keys", "(", ")", ":", "correct_alias", "=", "{", "path_to_node", "(", "path", ")", "}", "if", "self", ".", "aliases", "[", "node", ".",...
Return matched keyword. If the node alias on a correct keyword (and only it), it matches.
[ "Return", "matched", "keyword", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/iter_transformation.py#L58-L67
train
serge-sans-paille/pythran
pythran/optimizations/iter_transformation.py
IterTransformation.visit_Module
def visit_Module(self, node): """Add itertools import for imap, izip or ifilter iterator.""" self.generic_visit(node) import_alias = ast.alias(name='itertools', asname=mangle('itertools')) if self.use_itertools: importIt = ast.Import(names=[import_alias]) node.bod...
python
def visit_Module(self, node): """Add itertools import for imap, izip or ifilter iterator.""" self.generic_visit(node) import_alias = ast.alias(name='itertools', asname=mangle('itertools')) if self.use_itertools: importIt = ast.Import(names=[import_alias]) node.bod...
[ "def", "visit_Module", "(", "self", ",", "node", ")", ":", "self", ".", "generic_visit", "(", "node", ")", "import_alias", "=", "ast", ".", "alias", "(", "name", "=", "'itertools'", ",", "asname", "=", "mangle", "(", "'itertools'", ")", ")", "if", "sel...
Add itertools import for imap, izip or ifilter iterator.
[ "Add", "itertools", "import", "for", "imap", "izip", "or", "ifilter", "iterator", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/iter_transformation.py#L69-L76
train
serge-sans-paille/pythran
pythran/optimizations/iter_transformation.py
IterTransformation.visit_Call
def visit_Call(self, node): """Replace function call by its correct iterator if it is possible.""" if node in self.potential_iterator: matched_path = self.find_matching_builtin(node) if matched_path is None: return self.generic_visit(node) # Special h...
python
def visit_Call(self, node): """Replace function call by its correct iterator if it is possible.""" if node in self.potential_iterator: matched_path = self.find_matching_builtin(node) if matched_path is None: return self.generic_visit(node) # Special h...
[ "def", "visit_Call", "(", "self", ",", "node", ")", ":", "if", "node", "in", "self", ".", "potential_iterator", ":", "matched_path", "=", "self", ".", "find_matching_builtin", "(", "node", ")", "if", "matched_path", "is", "None", ":", "return", "self", "."...
Replace function call by its correct iterator if it is possible.
[ "Replace", "function", "call", "by", "its", "correct", "iterator", "if", "it", "is", "possible", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/iter_transformation.py#L78-L105
train
serge-sans-paille/pythran
docs/papers/iop2014/xp/numba/hyantes.py
run
def run(xmin, ymin, xmax, ymax, step, range_, range_x, range_y, t): X,Y = t.shape pt = np.zeros((X,Y)) "omp parallel for" for i in range(X): for j in range(Y): for k in t: tmp = 6368.* np.arccos( np.cos(xmin+step*i)*np.cos( k[0] ) * np.cos((ymin+step*j)-k[1])+ np.sin...
python
def run(xmin, ymin, xmax, ymax, step, range_, range_x, range_y, t): X,Y = t.shape pt = np.zeros((X,Y)) "omp parallel for" for i in range(X): for j in range(Y): for k in t: tmp = 6368.* np.arccos( np.cos(xmin+step*i)*np.cos( k[0] ) * np.cos((ymin+step*j)-k[1])+ np.sin...
[ "def", "run", "(", "xmin", ",", "ymin", ",", "xmax", ",", "ymax", ",", "step", ",", "range_", ",", "range_x", ",", "range_y", ",", "t", ")", ":", "X", ",", "Y", "=", "t", ".", "shape", "pt", "=", "np", ".", "zeros", "(", "(", "X", ",", "Y",...
omp parallel for
[ "omp", "parallel", "for" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/docs/papers/iop2014/xp/numba/hyantes.py#L4-L14
train
serge-sans-paille/pythran
pythran/interval.py
max_values
def max_values(args): """ Return possible range for max function. """ return Interval(max(x.low for x in args), max(x.high for x in args))
python
def max_values(args): """ Return possible range for max function. """ return Interval(max(x.low for x in args), max(x.high for x in args))
[ "def", "max_values", "(", "args", ")", ":", "return", "Interval", "(", "max", "(", "x", ".", "low", "for", "x", "in", "args", ")", ",", "max", "(", "x", ".", "high", "for", "x", "in", "args", ")", ")" ]
Return possible range for max function.
[ "Return", "possible", "range", "for", "max", "function", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/interval.py#L405-L407
train
serge-sans-paille/pythran
pythran/interval.py
min_values
def min_values(args): """ Return possible range for min function. """ return Interval(min(x.low for x in args), min(x.high for x in args))
python
def min_values(args): """ Return possible range for min function. """ return Interval(min(x.low for x in args), min(x.high for x in args))
[ "def", "min_values", "(", "args", ")", ":", "return", "Interval", "(", "min", "(", "x", ".", "low", "for", "x", "in", "args", ")", ",", "min", "(", "x", ".", "high", "for", "x", "in", "args", ")", ")" ]
Return possible range for min function.
[ "Return", "possible", "range", "for", "min", "function", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/interval.py#L410-L412
train
serge-sans-paille/pythran
pythran/interval.py
Interval.union
def union(self, other): """ Intersect current range with other.""" return Interval(min(self.low, other.low), max(self.high, other.high))
python
def union(self, other): """ Intersect current range with other.""" return Interval(min(self.low, other.low), max(self.high, other.high))
[ "def", "union", "(", "self", ",", "other", ")", ":", "return", "Interval", "(", "min", "(", "self", ".", "low", ",", "other", ".", "low", ")", ",", "max", "(", "self", ".", "high", ",", "other", ".", "high", ")", ")" ]
Intersect current range with other.
[ "Intersect", "current", "range", "with", "other", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/interval.py#L38-L40
train
serge-sans-paille/pythran
pythran/interval.py
Interval.widen
def widen(self, other): """ Widen current range. """ if self.low < other.low: low = -float("inf") else: low = self.low if self.high > other.high: high = float("inf") else: high = self.high return Interval(low, high)
python
def widen(self, other): """ Widen current range. """ if self.low < other.low: low = -float("inf") else: low = self.low if self.high > other.high: high = float("inf") else: high = self.high return Interval(low, high)
[ "def", "widen", "(", "self", ",", "other", ")", ":", "if", "self", ".", "low", "<", "other", ".", "low", ":", "low", "=", "-", "float", "(", "\"inf\"", ")", "else", ":", "low", "=", "self", ".", "low", "if", "self", ".", "high", ">", "other", ...
Widen current range.
[ "Widen", "current", "range", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/interval.py#L45-L55
train
serge-sans-paille/pythran
pythran/transformations/remove_named_arguments.py
RemoveNamedArguments.handle_keywords
def handle_keywords(self, func, node, offset=0): ''' Gather keywords to positional argument information Assumes the named parameter exist, raises a KeyError otherwise ''' func_argument_names = {} for i, arg in enumerate(func.args.args[offset:]): assert isinst...
python
def handle_keywords(self, func, node, offset=0): ''' Gather keywords to positional argument information Assumes the named parameter exist, raises a KeyError otherwise ''' func_argument_names = {} for i, arg in enumerate(func.args.args[offset:]): assert isinst...
[ "def", "handle_keywords", "(", "self", ",", "func", ",", "node", ",", "offset", "=", "0", ")", ":", "func_argument_names", "=", "{", "}", "for", "i", ",", "arg", "in", "enumerate", "(", "func", ".", "args", ".", "args", "[", "offset", ":", "]", ")"...
Gather keywords to positional argument information Assumes the named parameter exist, raises a KeyError otherwise
[ "Gather", "keywords", "to", "positional", "argument", "information" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/remove_named_arguments.py#L38-L62
train
serge-sans-paille/pythran
pythran/tables.py
update_effects
def update_effects(self, node): """ Combiner when we update the first argument of a function. It turn type of first parameter in combination of all others parameters types. """ return [self.combine(node.args[0], node_args_k, register=True, aliasing_type=True) ...
python
def update_effects(self, node): """ Combiner when we update the first argument of a function. It turn type of first parameter in combination of all others parameters types. """ return [self.combine(node.args[0], node_args_k, register=True, aliasing_type=True) ...
[ "def", "update_effects", "(", "self", ",", "node", ")", ":", "return", "[", "self", ".", "combine", "(", "node", ".", "args", "[", "0", "]", ",", "node_args_k", ",", "register", "=", "True", ",", "aliasing_type", "=", "True", ")", "for", "node_args_k",...
Combiner when we update the first argument of a function. It turn type of first parameter in combination of all others parameters types.
[ "Combiner", "when", "we", "update", "the", "first", "argument", "of", "a", "function", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/tables.py#L161-L170
train
serge-sans-paille/pythran
pythran/tables.py
save_method
def save_method(elements, module_path): """ Recursively save methods with module name and signature. """ for elem, signature in elements.items(): if isinstance(signature, dict): # Submodule case save_method(signature, module_path + (elem,)) elif isinstance(signature, Class): ...
python
def save_method(elements, module_path): """ Recursively save methods with module name and signature. """ for elem, signature in elements.items(): if isinstance(signature, dict): # Submodule case save_method(signature, module_path + (elem,)) elif isinstance(signature, Class): ...
[ "def", "save_method", "(", "elements", ",", "module_path", ")", ":", "for", "elem", ",", "signature", "in", "elements", ".", "items", "(", ")", ":", "if", "isinstance", "(", "signature", ",", "dict", ")", ":", "save_method", "(", "signature", ",", "modul...
Recursively save methods with module name and signature.
[ "Recursively", "save", "methods", "with", "module", "name", "and", "signature", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/tables.py#L4609-L4624
train
serge-sans-paille/pythran
pythran/tables.py
save_function
def save_function(elements, module_path): """ Recursively save functions with module name and signature. """ for elem, signature in elements.items(): if isinstance(signature, dict): # Submodule case save_function(signature, module_path + (elem,)) elif signature.isstaticfunction(): ...
python
def save_function(elements, module_path): """ Recursively save functions with module name and signature. """ for elem, signature in elements.items(): if isinstance(signature, dict): # Submodule case save_function(signature, module_path + (elem,)) elif signature.isstaticfunction(): ...
[ "def", "save_function", "(", "elements", ",", "module_path", ")", ":", "for", "elem", ",", "signature", "in", "elements", ".", "items", "(", ")", ":", "if", "isinstance", "(", "signature", ",", "dict", ")", ":", "save_function", "(", "signature", ",", "m...
Recursively save functions with module name and signature.
[ "Recursively", "save", "functions", "with", "module", "name", "and", "signature", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/tables.py#L4634-L4642
train
serge-sans-paille/pythran
pythran/tables.py
save_attribute
def save_attribute(elements, module_path): """ Recursively save attributes with module name and signature. """ for elem, signature in elements.items(): if isinstance(signature, dict): # Submodule case save_attribute(signature, module_path + (elem,)) elif signature.isattribute(): ...
python
def save_attribute(elements, module_path): """ Recursively save attributes with module name and signature. """ for elem, signature in elements.items(): if isinstance(signature, dict): # Submodule case save_attribute(signature, module_path + (elem,)) elif signature.isattribute(): ...
[ "def", "save_attribute", "(", "elements", ",", "module_path", ")", ":", "for", "elem", ",", "signature", "in", "elements", ".", "items", "(", ")", ":", "if", "isinstance", "(", "signature", ",", "dict", ")", ":", "save_attribute", "(", "signature", ",", ...
Recursively save attributes with module name and signature.
[ "Recursively", "save", "attributes", "with", "module", "name", "and", "signature", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/tables.py#L4653-L4662
train
serge-sans-paille/pythran
pythran/optimizations/list_to_tuple.py
ListToTuple.visit_Assign
def visit_Assign(self, node): """ Replace list calls by static_list calls when possible >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(n): x = __builtin__.list(n); x[0] = 0; return __builtin__.tuple(x)") >>> pm = passman...
python
def visit_Assign(self, node): """ Replace list calls by static_list calls when possible >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(n): x = __builtin__.list(n); x[0] = 0; return __builtin__.tuple(x)") >>> pm = passman...
[ "def", "visit_Assign", "(", "self", ",", "node", ")", ":", "self", ".", "generic_visit", "(", "node", ")", "if", "node", ".", "value", "not", "in", "self", ".", "fixed_size_list", ":", "return", "node", "node", ".", "value", "=", "self", ".", "convert"...
Replace list calls by static_list calls when possible >>> import gast as ast >>> from pythran import passmanager, backend >>> node = ast.parse("def foo(n): x = __builtin__.list(n); x[0] = 0; return __builtin__.tuple(x)") >>> pm = passmanager.PassManager("test") >>> _, node = pm....
[ "Replace", "list", "calls", "by", "static_list", "calls", "when", "possible" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/list_to_tuple.py#L66-L95
train
serge-sans-paille/pythran
setup.py
BuildWithThirdParty.copy_pkg
def copy_pkg(self, pkg, src_only=False): "Install boost deps from the third_party directory" if getattr(self, 'no_' + pkg) is None: print('Copying boost dependencies') to_copy = pkg, else: return src = os.path.join('third_party', *to_copy) #...
python
def copy_pkg(self, pkg, src_only=False): "Install boost deps from the third_party directory" if getattr(self, 'no_' + pkg) is None: print('Copying boost dependencies') to_copy = pkg, else: return src = os.path.join('third_party', *to_copy) #...
[ "def", "copy_pkg", "(", "self", ",", "pkg", ",", "src_only", "=", "False", ")", ":", "\"Install boost deps from the third_party directory\"", "if", "getattr", "(", "self", ",", "'no_'", "+", "pkg", ")", "is", "None", ":", "print", "(", "'Copying boost dependenci...
Install boost deps from the third_party directory
[ "Install", "boost", "deps", "from", "the", "third_party", "directory" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/setup.py#L75-L95
train
serge-sans-paille/pythran
pythran/analyses/ast_matcher.py
Check.check_list
def check_list(self, node_list, pattern_list): """ Check if list of node are equal. """ if len(node_list) != len(pattern_list): return False else: return all(Check(node_elt, self.placeholders).visit(pattern_list[i]) for ...
python
def check_list(self, node_list, pattern_list): """ Check if list of node are equal. """ if len(node_list) != len(pattern_list): return False else: return all(Check(node_elt, self.placeholders).visit(pattern_list[i]) for ...
[ "def", "check_list", "(", "self", ",", "node_list", ",", "pattern_list", ")", ":", "if", "len", "(", "node_list", ")", "!=", "len", "(", "pattern_list", ")", ":", "return", "False", "else", ":", "return", "all", "(", "Check", "(", "node_elt", ",", "sel...
Check if list of node are equal.
[ "Check", "if", "list", "of", "node", "are", "equal", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/ast_matcher.py#L67-L74
train
serge-sans-paille/pythran
pythran/analyses/ast_matcher.py
Check.visit_Placeholder
def visit_Placeholder(self, pattern): """ Save matching node or compare it with the existing one. FIXME : What if the new placeholder is a better choice? """ if (pattern.id in self.placeholders and not Check(self.node, self.placeholders).visit( ...
python
def visit_Placeholder(self, pattern): """ Save matching node or compare it with the existing one. FIXME : What if the new placeholder is a better choice? """ if (pattern.id in self.placeholders and not Check(self.node, self.placeholders).visit( ...
[ "def", "visit_Placeholder", "(", "self", ",", "pattern", ")", ":", "if", "(", "pattern", ".", "id", "in", "self", ".", "placeholders", "and", "not", "Check", "(", "self", ".", "node", ",", "self", ".", "placeholders", ")", ".", "visit", "(", "self", ...
Save matching node or compare it with the existing one. FIXME : What if the new placeholder is a better choice?
[ "Save", "matching", "node", "or", "compare", "it", "with", "the", "existing", "one", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/ast_matcher.py#L76-L88
train
serge-sans-paille/pythran
pythran/analyses/ast_matcher.py
Check.visit_AST_or
def visit_AST_or(self, pattern): """ Match if any of the or content match with the other node. """ return any(self.field_match(self.node, value_or) for value_or in pattern.args)
python
def visit_AST_or(self, pattern): """ Match if any of the or content match with the other node. """ return any(self.field_match(self.node, value_or) for value_or in pattern.args)
[ "def", "visit_AST_or", "(", "self", ",", "pattern", ")", ":", "return", "any", "(", "self", ".", "field_match", "(", "self", ".", "node", ",", "value_or", ")", "for", "value_or", "in", "pattern", ".", "args", ")" ]
Match if any of the or content match with the other node.
[ "Match", "if", "any", "of", "the", "or", "content", "match", "with", "the", "other", "node", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/ast_matcher.py#L95-L98
train
serge-sans-paille/pythran
pythran/analyses/ast_matcher.py
Check.visit_Set
def visit_Set(self, pattern): """ Set have unordered values. """ if len(pattern.elts) > MAX_UNORDERED_LENGTH: raise DamnTooLongPattern("Pattern for Set is too long") return (isinstance(self.node, Set) and any(self.check_list(self.node.elts, pattern_elts) ...
python
def visit_Set(self, pattern): """ Set have unordered values. """ if len(pattern.elts) > MAX_UNORDERED_LENGTH: raise DamnTooLongPattern("Pattern for Set is too long") return (isinstance(self.node, Set) and any(self.check_list(self.node.elts, pattern_elts) ...
[ "def", "visit_Set", "(", "self", ",", "pattern", ")", ":", "if", "len", "(", "pattern", ".", "elts", ")", ">", "MAX_UNORDERED_LENGTH", ":", "raise", "DamnTooLongPattern", "(", "\"Pattern for Set is too long\"", ")", "return", "(", "isinstance", "(", "self", "....
Set have unordered values.
[ "Set", "have", "unordered", "values", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/ast_matcher.py#L100-L106
train
serge-sans-paille/pythran
pythran/analyses/ast_matcher.py
Check.visit_Dict
def visit_Dict(self, pattern): """ Dict can match with unordered values. """ if not isinstance(self.node, Dict): return False if len(pattern.keys) > MAX_UNORDERED_LENGTH: raise DamnTooLongPattern("Pattern for Dict is too long") for permutation in permutations(rang...
python
def visit_Dict(self, pattern): """ Dict can match with unordered values. """ if not isinstance(self.node, Dict): return False if len(pattern.keys) > MAX_UNORDERED_LENGTH: raise DamnTooLongPattern("Pattern for Dict is too long") for permutation in permutations(rang...
[ "def", "visit_Dict", "(", "self", ",", "pattern", ")", ":", "if", "not", "isinstance", "(", "self", ".", "node", ",", "Dict", ")", ":", "return", "False", "if", "len", "(", "pattern", ".", "keys", ")", ">", "MAX_UNORDERED_LENGTH", ":", "raise", "DamnTo...
Dict can match with unordered values.
[ "Dict", "can", "match", "with", "unordered", "values", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/ast_matcher.py#L108-L122
train
serge-sans-paille/pythran
pythran/analyses/ast_matcher.py
Check.field_match
def field_match(self, node_field, pattern_field): """ Check if two fields match. Field match if: - If it is a list, all values have to match. - If if is a node, recursively check it. - Otherwise, check values are equal. """ is_good_list = (isi...
python
def field_match(self, node_field, pattern_field): """ Check if two fields match. Field match if: - If it is a list, all values have to match. - If if is a node, recursively check it. - Otherwise, check values are equal. """ is_good_list = (isi...
[ "def", "field_match", "(", "self", ",", "node_field", ",", "pattern_field", ")", ":", "is_good_list", "=", "(", "isinstance", "(", "pattern_field", ",", "list", ")", "and", "self", ".", "check_list", "(", "node_field", ",", "pattern_field", ")", ")", "is_goo...
Check if two fields match. Field match if: - If it is a list, all values have to match. - If if is a node, recursively check it. - Otherwise, check values are equal.
[ "Check", "if", "two", "fields", "match", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/ast_matcher.py#L124-L146
train
serge-sans-paille/pythran
pythran/analyses/ast_matcher.py
Check.generic_visit
def generic_visit(self, pattern): """ Check if the pattern match with the checked node. a node match if: - type match - all field match """ return (isinstance(pattern, type(self.node)) and all(self.field_match(value, getattr(pattern, field...
python
def generic_visit(self, pattern): """ Check if the pattern match with the checked node. a node match if: - type match - all field match """ return (isinstance(pattern, type(self.node)) and all(self.field_match(value, getattr(pattern, field...
[ "def", "generic_visit", "(", "self", ",", "pattern", ")", ":", "return", "(", "isinstance", "(", "pattern", ",", "type", "(", "self", ".", "node", ")", ")", "and", "all", "(", "self", ".", "field_match", "(", "value", ",", "getattr", "(", "pattern", ...
Check if the pattern match with the checked node. a node match if: - type match - all field match
[ "Check", "if", "the", "pattern", "match", "with", "the", "checked", "node", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/ast_matcher.py#L148-L158
train
serge-sans-paille/pythran
pythran/analyses/ast_matcher.py
ASTMatcher.visit
def visit(self, node): """ Visitor looking for matching between current node and pattern. If it match, save it but whatever happen, keep going. """ if Check(node, dict()).visit(self.pattern): self.result.add(node) self.generic_visit(node)
python
def visit(self, node): """ Visitor looking for matching between current node and pattern. If it match, save it but whatever happen, keep going. """ if Check(node, dict()).visit(self.pattern): self.result.add(node) self.generic_visit(node)
[ "def", "visit", "(", "self", ",", "node", ")", ":", "if", "Check", "(", "node", ",", "dict", "(", ")", ")", ".", "visit", "(", "self", ".", "pattern", ")", ":", "self", ".", "result", ".", "add", "(", "node", ")", "self", ".", "generic_visit", ...
Visitor looking for matching between current node and pattern. If it match, save it but whatever happen, keep going.
[ "Visitor", "looking", "for", "matching", "between", "current", "node", "and", "pattern", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/ast_matcher.py#L199-L207
train
serge-sans-paille/pythran
pythran/analyses/lazyness_analysis.py
LazynessAnalysis.visit_Call
def visit_Call(self, node): """ Compute use of variables in a function call. Each arg is use once and function name too. Information about modified arguments is forwarded to func_args_lazyness. """ md.visit(self, node) for arg in node.args: se...
python
def visit_Call(self, node): """ Compute use of variables in a function call. Each arg is use once and function name too. Information about modified arguments is forwarded to func_args_lazyness. """ md.visit(self, node) for arg in node.args: se...
[ "def", "visit_Call", "(", "self", ",", "node", ")", ":", "md", ".", "visit", "(", "self", ",", "node", ")", "for", "arg", "in", "node", ".", "args", ":", "self", ".", "visit", "(", "arg", ")", "self", ".", "func_args_lazyness", "(", "node", ".", ...
Compute use of variables in a function call. Each arg is use once and function name too. Information about modified arguments is forwarded to func_args_lazyness.
[ "Compute", "use", "of", "variables", "in", "a", "function", "call", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/lazyness_analysis.py#L359-L371
train
serge-sans-paille/pythran
docs/papers/iop2014/xp/numba/nqueens.py
n_queens
def n_queens(queen_count): """N-Queens solver. Args: queen_count: the number of queens to solve for. This is also the board size. Yields: Solutions to the problem. Each yielded value is looks like (3, 8, 2, 1, 4, ..., 6) where each number is the column position for the ...
python
def n_queens(queen_count): """N-Queens solver. Args: queen_count: the number of queens to solve for. This is also the board size. Yields: Solutions to the problem. Each yielded value is looks like (3, 8, 2, 1, 4, ..., 6) where each number is the column position for the ...
[ "def", "n_queens", "(", "queen_count", ")", ":", "out", "=", "list", "(", ")", "cols", "=", "range", "(", "queen_count", ")", "for", "vec", "in", "permutations", "(", "cols", ",", "None", ")", ":", "if", "(", "queen_count", "==", "len", "(", "set", ...
N-Queens solver. Args: queen_count: the number of queens to solve for. This is also the board size. Yields: Solutions to the problem. Each yielded value is looks like (3, 8, 2, 1, 4, ..., 6) where each number is the column position for the queen, and the index into ...
[ "N", "-", "Queens", "solver", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/docs/papers/iop2014/xp/numba/nqueens.py#L30-L50
train
serge-sans-paille/pythran
pythran/optimizations/inlining.py
Inlining.visit_Stmt
def visit_Stmt(self, node): """ Add new variable definition before the Statement. """ save_defs, self.defs = self.defs or list(), list() self.generic_visit(node) new_defs, self.defs = self.defs, save_defs return new_defs + [node]
python
def visit_Stmt(self, node): """ Add new variable definition before the Statement. """ save_defs, self.defs = self.defs or list(), list() self.generic_visit(node) new_defs, self.defs = self.defs, save_defs return new_defs + [node]
[ "def", "visit_Stmt", "(", "self", ",", "node", ")", ":", "save_defs", ",", "self", ".", "defs", "=", "self", ".", "defs", "or", "list", "(", ")", ",", "list", "(", ")", "self", ".", "generic_visit", "(", "node", ")", "new_defs", ",", "self", ".", ...
Add new variable definition before the Statement.
[ "Add", "new", "variable", "definition", "before", "the", "Statement", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/inlining.py#L44-L49
train
serge-sans-paille/pythran
pythran/optimizations/inlining.py
Inlining.visit_Call
def visit_Call(self, node): """ Replace function call by inlined function's body. We can inline if it aliases on only one function. """ func_aliases = self.aliases[node.func] if len(func_aliases) == 1: function_def = next(iter(func_aliases)) if (i...
python
def visit_Call(self, node): """ Replace function call by inlined function's body. We can inline if it aliases on only one function. """ func_aliases = self.aliases[node.func] if len(func_aliases) == 1: function_def = next(iter(func_aliases)) if (i...
[ "def", "visit_Call", "(", "self", ",", "node", ")", ":", "func_aliases", "=", "self", ".", "aliases", "[", "node", ".", "func", "]", "if", "len", "(", "func_aliases", ")", "==", "1", ":", "function_def", "=", "next", "(", "iter", "(", "func_aliases", ...
Replace function call by inlined function's body. We can inline if it aliases on only one function.
[ "Replace", "function", "call", "by", "inlined", "function", "s", "body", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/inlining.py#L62-L93
train
serge-sans-paille/pythran
pythran/conversion.py
size_container_folding
def size_container_folding(value): """ Convert value to ast expression if size is not too big. Converter for sized container. """ if len(value) < MAX_LEN: if isinstance(value, list): return ast.List([to_ast(elt) for elt in value], ast.Load()) elif isinstance(value, tuple...
python
def size_container_folding(value): """ Convert value to ast expression if size is not too big. Converter for sized container. """ if len(value) < MAX_LEN: if isinstance(value, list): return ast.List([to_ast(elt) for elt in value], ast.Load()) elif isinstance(value, tuple...
[ "def", "size_container_folding", "(", "value", ")", ":", "if", "len", "(", "value", ")", "<", "MAX_LEN", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "return", "ast", ".", "List", "(", "[", "to_ast", "(", "elt", ")", "for", "elt", ...
Convert value to ast expression if size is not too big. Converter for sized container.
[ "Convert", "value", "to", "ast", "expression", "if", "size", "is", "not", "too", "big", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/conversion.py#L34-L65
train
serge-sans-paille/pythran
pythran/conversion.py
builtin_folding
def builtin_folding(value): """ Convert builtin function to ast expression. """ if isinstance(value, (type(None), bool)): name = str(value) elif value.__name__ in ("bool", "float", "int"): name = value.__name__ + "_" else: name = value.__name__ return ast.Attribute(ast.Name('...
python
def builtin_folding(value): """ Convert builtin function to ast expression. """ if isinstance(value, (type(None), bool)): name = str(value) elif value.__name__ in ("bool", "float", "int"): name = value.__name__ + "_" else: name = value.__name__ return ast.Attribute(ast.Name('...
[ "def", "builtin_folding", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "type", "(", "None", ")", ",", "bool", ")", ")", ":", "name", "=", "str", "(", "value", ")", "elif", "value", ".", "__name__", "in", "(", "\"bool\"", ",",...
Convert builtin function to ast expression.
[ "Convert", "builtin", "function", "to", "ast", "expression", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/conversion.py#L68-L77
train
serge-sans-paille/pythran
pythran/conversion.py
to_ast
def to_ast(value): """ Turn a value into ast expression. >>> a = 1 >>> print(ast.dump(to_ast(a))) Num(n=1) >>> a = [1, 2, 3] >>> print(ast.dump(to_ast(a))) List(elts=[Num(n=1), Num(n=2), Num(n=3)], ctx=Load()) """ if isinstance(value, (type(None), bool)): return builtin...
python
def to_ast(value): """ Turn a value into ast expression. >>> a = 1 >>> print(ast.dump(to_ast(a))) Num(n=1) >>> a = [1, 2, 3] >>> print(ast.dump(to_ast(a))) List(elts=[Num(n=1), Num(n=2), Num(n=3)], ctx=Load()) """ if isinstance(value, (type(None), bool)): return builtin...
[ "def", "to_ast", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "type", "(", "None", ")", ",", "bool", ")", ")", ":", "return", "builtin_folding", "(", "value", ")", "if", "sys", ".", "version_info", "[", "0", "]", "==", "2", ...
Turn a value into ast expression. >>> a = 1 >>> print(ast.dump(to_ast(a))) Num(n=1) >>> a = [1, 2, 3] >>> print(ast.dump(to_ast(a))) List(elts=[Num(n=1), Num(n=2), Num(n=3)], ctx=Load())
[ "Turn", "a", "value", "into", "ast", "expression", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/conversion.py#L80-L118
train
serge-sans-paille/pythran
pythran/analyses/global_declarations.py
GlobalDeclarations.visit_Module
def visit_Module(self, node): """ Import module define a new variable name. """ duc = SilentDefUseChains() duc.visit(node) for d in duc.locals[node]: self.result[d.name()] = d.node
python
def visit_Module(self, node): """ Import module define a new variable name. """ duc = SilentDefUseChains() duc.visit(node) for d in duc.locals[node]: self.result[d.name()] = d.node
[ "def", "visit_Module", "(", "self", ",", "node", ")", ":", "duc", "=", "SilentDefUseChains", "(", ")", "duc", ".", "visit", "(", "node", ")", "for", "d", "in", "duc", ".", "locals", "[", "node", "]", ":", "self", ".", "result", "[", "d", ".", "na...
Import module define a new variable name.
[ "Import", "module", "define", "a", "new", "variable", "name", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/global_declarations.py#L39-L44
train
serge-sans-paille/pythran
pythran/utils.py
attr_to_path
def attr_to_path(node): """ Compute path and final object for an attribute node """ def get_intrinsic_path(modules, attr): """ Get function path and intrinsic from an ast.Attribute. """ if isinstance(attr, ast.Name): return modules[demangle(attr.id)], (demangle(attr.id),) e...
python
def attr_to_path(node): """ Compute path and final object for an attribute node """ def get_intrinsic_path(modules, attr): """ Get function path and intrinsic from an ast.Attribute. """ if isinstance(attr, ast.Name): return modules[demangle(attr.id)], (demangle(attr.id),) e...
[ "def", "attr_to_path", "(", "node", ")", ":", "def", "get_intrinsic_path", "(", "modules", ",", "attr", ")", ":", "if", "isinstance", "(", "attr", ",", "ast", ".", "Name", ")", ":", "return", "modules", "[", "demangle", "(", "attr", ".", "id", ")", "...
Compute path and final object for an attribute node
[ "Compute", "path", "and", "final", "object", "for", "an", "attribute", "node" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/utils.py#L10-L23
train
serge-sans-paille/pythran
pythran/utils.py
path_to_attr
def path_to_attr(path): """ Transform path to ast.Attribute. >>> import gast as ast >>> path = ('__builtin__', 'my', 'constant') >>> value = path_to_attr(path) >>> ref = ast.Attribute( ... value=ast.Attribute(value=ast.Name(id="__builtin__", ... ...
python
def path_to_attr(path): """ Transform path to ast.Attribute. >>> import gast as ast >>> path = ('__builtin__', 'my', 'constant') >>> value = path_to_attr(path) >>> ref = ast.Attribute( ... value=ast.Attribute(value=ast.Name(id="__builtin__", ... ...
[ "def", "path_to_attr", "(", "path", ")", ":", "return", "reduce", "(", "lambda", "hpath", ",", "last", ":", "ast", ".", "Attribute", "(", "hpath", ",", "last", ",", "ast", ".", "Load", "(", ")", ")", ",", "path", "[", "1", ":", "]", ",", "ast", ...
Transform path to ast.Attribute. >>> import gast as ast >>> path = ('__builtin__', 'my', 'constant') >>> value = path_to_attr(path) >>> ref = ast.Attribute( ... value=ast.Attribute(value=ast.Name(id="__builtin__", ... ctx=ast.Load(), ... ...
[ "Transform", "path", "to", "ast", ".", "Attribute", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/utils.py#L26-L43
train
serge-sans-paille/pythran
pythran/utils.py
get_variable
def get_variable(assignable): """ Return modified variable name. >>> import gast as ast >>> ref = ast.Subscript( ... value=ast.Subscript( ... value=ast.Name(id='a', ctx=ast.Load(), annotation=None), ... slice=ast.Index(value=ast.Name('i', ast.Load(), None)), ... ...
python
def get_variable(assignable): """ Return modified variable name. >>> import gast as ast >>> ref = ast.Subscript( ... value=ast.Subscript( ... value=ast.Name(id='a', ctx=ast.Load(), annotation=None), ... slice=ast.Index(value=ast.Name('i', ast.Load(), None)), ... ...
[ "def", "get_variable", "(", "assignable", ")", ":", "msg", "=", "\"Only name and subscript can be assigned.\"", "assert", "isinstance", "(", "assignable", ",", "(", "ast", ".", "Name", ",", "ast", ".", "Subscript", ")", ")", ",", "msg", "while", "isinstance", ...
Return modified variable name. >>> import gast as ast >>> ref = ast.Subscript( ... value=ast.Subscript( ... value=ast.Name(id='a', ctx=ast.Load(), annotation=None), ... slice=ast.Index(value=ast.Name('i', ast.Load(), None)), ... ctx=ast.Load()), ... slice=ast...
[ "Return", "modified", "variable", "name", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/utils.py#L64-L87
train
serge-sans-paille/pythran
pythran/types/reorder.py
Reorder.prepare
def prepare(self, node): """ Format type dependencies information to use if for reordering. """ super(Reorder, self).prepare(node) candidates = self.type_dependencies.successors( TypeDependencies.NoDeps) # We first select function which may have a result without calling any ...
python
def prepare(self, node): """ Format type dependencies information to use if for reordering. """ super(Reorder, self).prepare(node) candidates = self.type_dependencies.successors( TypeDependencies.NoDeps) # We first select function which may have a result without calling any ...
[ "def", "prepare", "(", "self", ",", "node", ")", ":", "super", "(", "Reorder", ",", "self", ")", ".", "prepare", "(", "node", ")", "candidates", "=", "self", ".", "type_dependencies", ".", "successors", "(", "TypeDependencies", ".", "NoDeps", ")", "while...
Format type dependencies information to use if for reordering.
[ "Format", "type", "dependencies", "information", "to", "use", "if", "for", "reordering", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/reorder.py#L57-L91
train
serge-sans-paille/pythran
pythran/types/reorder.py
Reorder.visit_Module
def visit_Module(self, node): """ Keep everything but function definition then add sorted functions. Most of the time, many function sort work so we use function calldepth as a "sort hint" to simplify typing. """ newbody = list() olddef = list() for stmt ...
python
def visit_Module(self, node): """ Keep everything but function definition then add sorted functions. Most of the time, many function sort work so we use function calldepth as a "sort hint" to simplify typing. """ newbody = list() olddef = list() for stmt ...
[ "def", "visit_Module", "(", "self", ",", "node", ")", ":", "newbody", "=", "list", "(", ")", "olddef", "=", "list", "(", ")", "for", "stmt", "in", "node", ".", "body", ":", "if", "isinstance", "(", "stmt", ",", "ast", ".", "FunctionDef", ")", ":", ...
Keep everything but function definition then add sorted functions. Most of the time, many function sort work so we use function calldepth as a "sort hint" to simplify typing.
[ "Keep", "everything", "but", "function", "definition", "then", "add", "sorted", "functions", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/reorder.py#L93-L118
train
serge-sans-paille/pythran
pythran/optimizations/dead_code_elimination.py
DeadCodeElimination.visit
def visit(self, node): """ Add OMPDirective from the old node to the new one. """ old_omp = metadata.get(node, OMPDirective) node = super(DeadCodeElimination, self).visit(node) if not metadata.get(node, OMPDirective): for omp_directive in old_omp: metadata.add...
python
def visit(self, node): """ Add OMPDirective from the old node to the new one. """ old_omp = metadata.get(node, OMPDirective) node = super(DeadCodeElimination, self).visit(node) if not metadata.get(node, OMPDirective): for omp_directive in old_omp: metadata.add...
[ "def", "visit", "(", "self", ",", "node", ")", ":", "old_omp", "=", "metadata", ".", "get", "(", "node", ",", "OMPDirective", ")", "node", "=", "super", "(", "DeadCodeElimination", ",", "self", ")", ".", "visit", "(", "node", ")", "if", "not", "metad...
Add OMPDirective from the old node to the new one.
[ "Add", "OMPDirective", "from", "the", "old", "node", "to", "the", "new", "one", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/optimizations/dead_code_elimination.py#L133-L140
train
serge-sans-paille/pythran
pythran/analyses/aliases.py
save_intrinsic_alias
def save_intrinsic_alias(module): """ Recursively save default aliases for pythonic functions. """ for v in module.values(): if isinstance(v, dict): # Submodules case save_intrinsic_alias(v) else: IntrinsicAliases[v] = frozenset((v,)) if isinstance(v, Class):...
python
def save_intrinsic_alias(module): """ Recursively save default aliases for pythonic functions. """ for v in module.values(): if isinstance(v, dict): # Submodules case save_intrinsic_alias(v) else: IntrinsicAliases[v] = frozenset((v,)) if isinstance(v, Class):...
[ "def", "save_intrinsic_alias", "(", "module", ")", ":", "for", "v", "in", "module", ".", "values", "(", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "save_intrinsic_alias", "(", "v", ")", "else", ":", "IntrinsicAliases", "[", "v", "]"...
Recursively save default aliases for pythonic functions.
[ "Recursively", "save", "default", "aliases", "for", "pythonic", "functions", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/aliases.py#L53-L61
train
serge-sans-paille/pythran
pythran/analyses/aliases.py
Aliases.visit_IfExp
def visit_IfExp(self, node): ''' Resulting node alias to either branch >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b, c): return a if c else b') >>> result = pm.gather(Aliases, module) >>> Aliase...
python
def visit_IfExp(self, node): ''' Resulting node alias to either branch >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b, c): return a if c else b') >>> result = pm.gather(Aliases, module) >>> Aliase...
[ "def", "visit_IfExp", "(", "self", ",", "node", ")", ":", "self", ".", "visit", "(", "node", ".", "test", ")", "rec", "=", "[", "self", ".", "visit", "(", "n", ")", "for", "n", "in", "(", "node", ".", "body", ",", "node", ".", "orelse", ")", ...
Resulting node alias to either branch >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b, c): return a if c else b') >>> result = pm.gather(Aliases, module) >>> Aliases.dump(result, filter=ast.IfExp) (a if c ...
[ "Resulting", "node", "alias", "to", "either", "branch" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/aliases.py#L164-L177
train
serge-sans-paille/pythran
pythran/analyses/aliases.py
Aliases.visit_Dict
def visit_Dict(self, node): ''' A dict is abstracted as an unordered container of its values >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return {0: a, 1: b}') >>> result = pm.gather(Aliases, module) ...
python
def visit_Dict(self, node): ''' A dict is abstracted as an unordered container of its values >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return {0: a, 1: b}') >>> result = pm.gather(Aliases, module) ...
[ "def", "visit_Dict", "(", "self", ",", "node", ")", ":", "if", "node", ".", "keys", ":", "elts_aliases", "=", "set", "(", ")", "for", "key", ",", "val", "in", "zip", "(", "node", ".", "keys", ",", "node", ".", "values", ")", ":", "self", ".", "...
A dict is abstracted as an unordered container of its values >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return {0: a, 1: b}') >>> result = pm.gather(Aliases, module) >>> Aliases.dump(result, filter=ast.Dict...
[ "A", "dict", "is", "abstracted", "as", "an", "unordered", "container", "of", "its", "values" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/aliases.py#L179-L200
train
serge-sans-paille/pythran
pythran/analyses/aliases.py
Aliases.visit_Set
def visit_Set(self, node): ''' A set is abstracted as an unordered container of its elements >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return {a, b}') >>> result = pm.gather(Aliases, module) ...
python
def visit_Set(self, node): ''' A set is abstracted as an unordered container of its elements >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return {a, b}') >>> result = pm.gather(Aliases, module) ...
[ "def", "visit_Set", "(", "self", ",", "node", ")", ":", "if", "node", ".", "elts", ":", "elts_aliases", "=", "{", "ContainerOf", "(", "alias", ")", "for", "elt", "in", "node", ".", "elts", "for", "alias", "in", "self", ".", "visit", "(", "elt", ")"...
A set is abstracted as an unordered container of its elements >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return {a, b}') >>> result = pm.gather(Aliases, module) >>> Aliases.dump(result, filter=ast.Set) ...
[ "A", "set", "is", "abstracted", "as", "an", "unordered", "container", "of", "its", "elements" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/aliases.py#L202-L221
train
serge-sans-paille/pythran
pythran/analyses/aliases.py
Aliases.visit_Return
def visit_Return(self, node): ''' A side effect of computing aliases on a Return is that it updates the ``return_alias`` field of current function >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return a...
python
def visit_Return(self, node): ''' A side effect of computing aliases on a Return is that it updates the ``return_alias`` field of current function >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return a...
[ "def", "visit_Return", "(", "self", ",", "node", ")", ":", "if", "not", "node", ".", "value", ":", "return", "ret_aliases", "=", "self", ".", "visit", "(", "node", ".", "value", ")", "if", "Aliases", ".", "RetId", "in", "self", ".", "aliases", ":", ...
A side effect of computing aliases on a Return is that it updates the ``return_alias`` field of current function >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return a') >>> result = pm.gather(Aliases, module)...
[ "A", "side", "effect", "of", "computing", "aliases", "on", "a", "Return", "is", "that", "it", "updates", "the", "return_alias", "field", "of", "current", "function" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/aliases.py#L223-L263
train
serge-sans-paille/pythran
pythran/analyses/aliases.py
Aliases.visit_Subscript
def visit_Subscript(self, node): ''' Resulting node alias stores the subscript relationship if we don't know anything about the subscripted node. >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a): return a[0]'...
python
def visit_Subscript(self, node): ''' Resulting node alias stores the subscript relationship if we don't know anything about the subscripted node. >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a): return a[0]'...
[ "def", "visit_Subscript", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ".", "slice", ",", "ast", ".", "Index", ")", ":", "aliases", "=", "set", "(", ")", "self", ".", "visit", "(", "node", ".", "slice", ")", "value_aliases", ...
Resulting node alias stores the subscript relationship if we don't know anything about the subscripted node. >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a): return a[0]') >>> result = pm.gather(Aliases, module) ...
[ "Resulting", "node", "alias", "stores", "the", "subscript", "relationship", "if", "we", "don", "t", "know", "anything", "about", "the", "subscripted", "node", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/aliases.py#L388-L445
train
serge-sans-paille/pythran
pythran/analyses/aliases.py
Aliases.visit_Tuple
def visit_Tuple(self, node): ''' A tuple is abstracted as an ordered container of its values >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return a, b') >>> result = pm.gather(Aliases, module) ...
python
def visit_Tuple(self, node): ''' A tuple is abstracted as an ordered container of its values >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return a, b') >>> result = pm.gather(Aliases, module) ...
[ "def", "visit_Tuple", "(", "self", ",", "node", ")", ":", "if", "node", ".", "elts", ":", "elts_aliases", "=", "set", "(", ")", "for", "i", ",", "elt", "in", "enumerate", "(", "node", ".", "elts", ")", ":", "elt_aliases", "=", "self", ".", "visit",...
A tuple is abstracted as an ordered container of its values >>> from pythran import passmanager >>> pm = passmanager.PassManager('demo') >>> module = ast.parse('def foo(a, b): return a, b') >>> result = pm.gather(Aliases, module) >>> Aliases.dump(result, filter=ast.Tuple) ...
[ "A", "tuple", "is", "abstracted", "as", "an", "ordered", "container", "of", "its", "values" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/aliases.py#L463-L485
train