id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
237,700 | serge-sans-paille/pythran | pythran/passmanager.py | uncamel | def uncamel(name):
"""Transform CamelCase naming convention into C-ish convention."""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | python | def uncamel(name):
"""Transform CamelCase naming convention into C-ish convention."""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | [
"def",
"uncamel",
"(",
"name",
")",
":",
"s1",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"name",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"s1",
")",
".",
"lower",
"(",
")"
] | Transform CamelCase naming convention into C-ish convention. | [
"Transform",
"CamelCase",
"naming",
"convention",
"into",
"C",
"-",
"ish",
"convention",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L19-L22 |
237,701 | serge-sans-paille/pythran | pythran/passmanager.py | ContextManager.verify_dependencies | def verify_dependencies(self):
"""
Checks no analysis are called before a transformation,
as the transformation could invalidate the analysis.
"""
for i in range(1, len(self.deps)):
assert(not (isinstance(self.deps[i], Transformation) and
isinstanc... | python | def verify_dependencies(self):
"""
Checks no analysis are called before a transformation,
as the transformation could invalidate the analysis.
"""
for i in range(1, len(self.deps)):
assert(not (isinstance(self.deps[i], Transformation) and
isinstanc... | [
"def",
"verify_dependencies",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"self",
".",
"deps",
")",
")",
":",
"assert",
"(",
"not",
"(",
"isinstance",
"(",
"self",
".",
"deps",
"[",
"i",
"]",
",",
"Transformation",
... | Checks no analysis are called before a transformation,
as the transformation could invalidate the analysis. | [
"Checks",
"no",
"analysis",
"are",
"called",
"before",
"a",
"transformation",
"as",
"the",
"transformation",
"could",
"invalidate",
"the",
"analysis",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L58-L67 |
237,702 | serge-sans-paille/pythran | pythran/passmanager.py | ContextManager.prepare | def prepare(self, node):
'''Gather analysis result required by this analysis'''
if isinstance(node, ast.Module):
self.ctx.module = node
elif isinstance(node, ast.FunctionDef):
self.ctx.function = node
for D in self.deps:
d = D()
d.attach(s... | python | def prepare(self, node):
'''Gather analysis result required by this analysis'''
if isinstance(node, ast.Module):
self.ctx.module = node
elif isinstance(node, ast.FunctionDef):
self.ctx.function = node
for D in self.deps:
d = D()
d.attach(s... | [
"def",
"prepare",
"(",
"self",
",",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Module",
")",
":",
"self",
".",
"ctx",
".",
"module",
"=",
"node",
"elif",
"isinstance",
"(",
"node",
",",
"ast",
".",
"FunctionDef",
")",
":",... | Gather analysis result required by this analysis | [
"Gather",
"analysis",
"result",
"required",
"by",
"this",
"analysis"
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L80-L91 |
237,703 | serge-sans-paille/pythran | pythran/passmanager.py | Transformation.run | def run(self, node):
""" Apply transformation and dependencies and fix new node location."""
n = super(Transformation, self).run(node)
if self.update:
ast.fix_missing_locations(n)
self.passmanager._cache.clear()
return n | python | def run(self, node):
""" Apply transformation and dependencies and fix new node location."""
n = super(Transformation, self).run(node)
if self.update:
ast.fix_missing_locations(n)
self.passmanager._cache.clear()
return n | [
"def",
"run",
"(",
"self",
",",
"node",
")",
":",
"n",
"=",
"super",
"(",
"Transformation",
",",
"self",
")",
".",
"run",
"(",
"node",
")",
"if",
"self",
".",
"update",
":",
"ast",
".",
"fix_missing_locations",
"(",
"n",
")",
"self",
".",
"passmana... | Apply transformation and dependencies and fix new node location. | [
"Apply",
"transformation",
"and",
"dependencies",
"and",
"fix",
"new",
"node",
"location",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L183-L189 |
237,704 | serge-sans-paille/pythran | pythran/passmanager.py | Transformation.apply | def apply(self, node):
""" Apply transformation and return if an update happened. """
new_node = self.run(node)
return self.update, new_node | python | def apply(self, node):
""" Apply transformation and return if an update happened. """
new_node = self.run(node)
return self.update, new_node | [
"def",
"apply",
"(",
"self",
",",
"node",
")",
":",
"new_node",
"=",
"self",
".",
"run",
"(",
"node",
")",
"return",
"self",
".",
"update",
",",
"new_node"
] | Apply transformation and return if an update happened. | [
"Apply",
"transformation",
"and",
"return",
"if",
"an",
"update",
"happened",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L191-L194 |
237,705 | serge-sans-paille/pythran | pythran/passmanager.py | PassManager.gather | def gather(self, analysis, node):
"High-level function to call an `analysis' on a `node'"
assert issubclass(analysis, Analysis)
a = analysis()
a.attach(self)
return a.run(node) | python | def gather(self, analysis, node):
"High-level function to call an `analysis' on a `node'"
assert issubclass(analysis, Analysis)
a = analysis()
a.attach(self)
return a.run(node) | [
"def",
"gather",
"(",
"self",
",",
"analysis",
",",
"node",
")",
":",
"assert",
"issubclass",
"(",
"analysis",
",",
"Analysis",
")",
"a",
"=",
"analysis",
"(",
")",
"a",
".",
"attach",
"(",
"self",
")",
"return",
"a",
".",
"run",
"(",
"node",
")"
] | High-level function to call an `analysis' on a `node | [
"High",
"-",
"level",
"function",
"to",
"call",
"an",
"analysis",
"on",
"a",
"node"
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L206-L211 |
237,706 | serge-sans-paille/pythran | pythran/passmanager.py | PassManager.dump | def dump(self, backend, node):
'''High-level function to call a `backend' on a `node' to generate
code for module `module_name'.'''
assert issubclass(backend, Backend)
b = backend()
b.attach(self)
return b.run(node) | python | def dump(self, backend, node):
'''High-level function to call a `backend' on a `node' to generate
code for module `module_name'.'''
assert issubclass(backend, Backend)
b = backend()
b.attach(self)
return b.run(node) | [
"def",
"dump",
"(",
"self",
",",
"backend",
",",
"node",
")",
":",
"assert",
"issubclass",
"(",
"backend",
",",
"Backend",
")",
"b",
"=",
"backend",
"(",
")",
"b",
".",
"attach",
"(",
"self",
")",
"return",
"b",
".",
"run",
"(",
"node",
")"
] | High-level function to call a `backend' on a `node' to generate
code for module `module_name'. | [
"High",
"-",
"level",
"function",
"to",
"call",
"a",
"backend",
"on",
"a",
"node",
"to",
"generate",
"code",
"for",
"module",
"module_name",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L213-L219 |
237,707 | serge-sans-paille/pythran | pythran/passmanager.py | PassManager.apply | def apply(self, transformation, node):
'''
High-level function to call a `transformation' on a `node'.
If the transformation is an analysis, the result of the analysis
is displayed.
'''
assert issubclass(transformation, (Transformation, Analysis))
a = transformati... | python | def apply(self, transformation, node):
'''
High-level function to call a `transformation' on a `node'.
If the transformation is an analysis, the result of the analysis
is displayed.
'''
assert issubclass(transformation, (Transformation, Analysis))
a = transformati... | [
"def",
"apply",
"(",
"self",
",",
"transformation",
",",
"node",
")",
":",
"assert",
"issubclass",
"(",
"transformation",
",",
"(",
"Transformation",
",",
"Analysis",
")",
")",
"a",
"=",
"transformation",
"(",
")",
"a",
".",
"attach",
"(",
"self",
")",
... | High-level function to call a `transformation' on a `node'.
If the transformation is an analysis, the result of the analysis
is displayed. | [
"High",
"-",
"level",
"function",
"to",
"call",
"a",
"transformation",
"on",
"a",
"node",
".",
"If",
"the",
"transformation",
"is",
"an",
"analysis",
"the",
"result",
"of",
"the",
"analysis",
"is",
"displayed",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L221-L238 |
237,708 | serge-sans-paille/pythran | pythran/types/conversion.py | pytype_to_ctype | def pytype_to_ctype(t):
""" Python -> pythonic type binding. """
if isinstance(t, List):
return 'pythonic::types::list<{0}>'.format(
pytype_to_ctype(t.__args__[0])
)
elif isinstance(t, Set):
return 'pythonic::types::set<{0}>'.format(
pytype_to_ctype(t.__args__... | python | def pytype_to_ctype(t):
""" Python -> pythonic type binding. """
if isinstance(t, List):
return 'pythonic::types::list<{0}>'.format(
pytype_to_ctype(t.__args__[0])
)
elif isinstance(t, Set):
return 'pythonic::types::set<{0}>'.format(
pytype_to_ctype(t.__args__... | [
"def",
"pytype_to_ctype",
"(",
"t",
")",
":",
"if",
"isinstance",
"(",
"t",
",",
"List",
")",
":",
"return",
"'pythonic::types::list<{0}>'",
".",
"format",
"(",
"pytype_to_ctype",
"(",
"t",
".",
"__args__",
"[",
"0",
"]",
")",
")",
"elif",
"isinstance",
... | Python -> pythonic type binding. | [
"Python",
"-",
">",
"pythonic",
"type",
"binding",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/conversion.py#L43-L92 |
237,709 | serge-sans-paille/pythran | pythran/types/conversion.py | pytype_to_pretty_type | def pytype_to_pretty_type(t):
""" Python -> docstring type. """
if isinstance(t, List):
return '{0} list'.format(pytype_to_pretty_type(t.__args__[0]))
elif isinstance(t, Set):
return '{0} set'.format(pytype_to_pretty_type(t.__args__[0]))
elif isinstance(t, Dict):
tkey, tvalue = t... | python | def pytype_to_pretty_type(t):
""" Python -> docstring type. """
if isinstance(t, List):
return '{0} list'.format(pytype_to_pretty_type(t.__args__[0]))
elif isinstance(t, Set):
return '{0} set'.format(pytype_to_pretty_type(t.__args__[0]))
elif isinstance(t, Dict):
tkey, tvalue = t... | [
"def",
"pytype_to_pretty_type",
"(",
"t",
")",
":",
"if",
"isinstance",
"(",
"t",
",",
"List",
")",
":",
"return",
"'{0} list'",
".",
"format",
"(",
"pytype_to_pretty_type",
"(",
"t",
".",
"__args__",
"[",
"0",
"]",
")",
")",
"elif",
"isinstance",
"(",
... | Python -> docstring type. | [
"Python",
"-",
">",
"docstring",
"type",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/conversion.py#L95-L133 |
237,710 | serge-sans-paille/pythran | pythran/types/tog.py | get_type | def get_type(name, env, non_generic):
"""Get the type of identifier name from the type environment env.
Args:
name: The identifier name
env: The type environment mapping from identifier names to types
non_generic: A set of non-generic TypeVariables
Raises:
ParseError: Raise... | python | def get_type(name, env, non_generic):
"""Get the type of identifier name from the type environment env.
Args:
name: The identifier name
env: The type environment mapping from identifier names to types
non_generic: A set of non-generic TypeVariables
Raises:
ParseError: Raise... | [
"def",
"get_type",
"(",
"name",
",",
"env",
",",
"non_generic",
")",
":",
"if",
"name",
"in",
"env",
":",
"if",
"isinstance",
"(",
"env",
"[",
"name",
"]",
",",
"MultiType",
")",
":",
"return",
"clone",
"(",
"env",
"[",
"name",
"]",
")",
"return",
... | Get the type of identifier name from the type environment env.
Args:
name: The identifier name
env: The type environment mapping from identifier names to types
non_generic: A set of non-generic TypeVariables
Raises:
ParseError: Raised if name is an undefined symbol in the type
... | [
"Get",
"the",
"type",
"of",
"identifier",
"name",
"from",
"the",
"type",
"environment",
"env",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/tog.py#L1170-L1188 |
237,711 | serge-sans-paille/pythran | pythran/types/tog.py | fresh | def fresh(t, non_generic):
"""Makes a copy of a type expression.
The type t is copied. The generic variables are duplicated and the
non_generic variables are shared.
Args:
t: A type to be copied.
non_generic: A set of non-generic TypeVariables
"""
mappings = {} # A mapping of... | python | def fresh(t, non_generic):
"""Makes a copy of a type expression.
The type t is copied. The generic variables are duplicated and the
non_generic variables are shared.
Args:
t: A type to be copied.
non_generic: A set of non-generic TypeVariables
"""
mappings = {} # A mapping of... | [
"def",
"fresh",
"(",
"t",
",",
"non_generic",
")",
":",
"mappings",
"=",
"{",
"}",
"# A mapping of TypeVariables to TypeVariables",
"def",
"freshrec",
"(",
"tp",
")",
":",
"p",
"=",
"prune",
"(",
"tp",
")",
"if",
"isinstance",
"(",
"p",
",",
"TypeVariable"... | Makes a copy of a type expression.
The type t is copied. The generic variables are duplicated and the
non_generic variables are shared.
Args:
t: A type to be copied.
non_generic: A set of non-generic TypeVariables | [
"Makes",
"a",
"copy",
"of",
"a",
"type",
"expression",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/tog.py#L1191-L1226 |
237,712 | serge-sans-paille/pythran | pythran/types/tog.py | prune | def prune(t):
"""Returns the currently defining instance of t.
As a side effect, collapses the list of type instances. The function Prune
is used whenever a type expression has to be inspected: it will always
return a type expression which is either an uninstantiated type variable or
a type operato... | python | def prune(t):
"""Returns the currently defining instance of t.
As a side effect, collapses the list of type instances. The function Prune
is used whenever a type expression has to be inspected: it will always
return a type expression which is either an uninstantiated type variable or
a type operato... | [
"def",
"prune",
"(",
"t",
")",
":",
"if",
"isinstance",
"(",
"t",
",",
"TypeVariable",
")",
":",
"if",
"t",
".",
"instance",
"is",
"not",
"None",
":",
"t",
".",
"instance",
"=",
"prune",
"(",
"t",
".",
"instance",
")",
"return",
"t",
".",
"instan... | Returns the currently defining instance of t.
As a side effect, collapses the list of type instances. The function Prune
is used whenever a type expression has to be inspected: it will always
return a type expression which is either an uninstantiated type variable or
a type operator; i.e. it will skip ... | [
"Returns",
"the",
"currently",
"defining",
"instance",
"of",
"t",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/tog.py#L1352-L1372 |
237,713 | serge-sans-paille/pythran | pythran/types/tog.py | occurs_in_type | def occurs_in_type(v, type2):
"""Checks whether a type variable occurs in a type expression.
Note: Must be called with v pre-pruned
Args:
v: The TypeVariable to be tested for
type2: The type in which to search
Returns:
True if v occurs in type2, otherwise False
"""
pr... | python | def occurs_in_type(v, type2):
"""Checks whether a type variable occurs in a type expression.
Note: Must be called with v pre-pruned
Args:
v: The TypeVariable to be tested for
type2: The type in which to search
Returns:
True if v occurs in type2, otherwise False
"""
pr... | [
"def",
"occurs_in_type",
"(",
"v",
",",
"type2",
")",
":",
"pruned_type2",
"=",
"prune",
"(",
"type2",
")",
"if",
"pruned_type2",
"==",
"v",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"pruned_type2",
",",
"TypeOperator",
")",
":",
"return",
"occurs_... | Checks whether a type variable occurs in a type expression.
Note: Must be called with v pre-pruned
Args:
v: The TypeVariable to be tested for
type2: The type in which to search
Returns:
True if v occurs in type2, otherwise False | [
"Checks",
"whether",
"a",
"type",
"variable",
"occurs",
"in",
"a",
"type",
"expression",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/tog.py#L1394-L1411 |
237,714 | serge-sans-paille/pythran | pythran/transformations/expand_imports.py | ExpandImports.visit_Module | def visit_Module(self, node):
"""
Visit the whole module and add all import at the top level.
>> import numpy.linalg
Becomes
>> import numpy
"""
node.body = [k for k in (self.visit(n) for n in node.body) if k]
imports = [ast.Import([ast.alias(i, mangle... | python | def visit_Module(self, node):
"""
Visit the whole module and add all import at the top level.
>> import numpy.linalg
Becomes
>> import numpy
"""
node.body = [k for k in (self.visit(n) for n in node.body) if k]
imports = [ast.Import([ast.alias(i, mangle... | [
"def",
"visit_Module",
"(",
"self",
",",
"node",
")",
":",
"node",
".",
"body",
"=",
"[",
"k",
"for",
"k",
"in",
"(",
"self",
".",
"visit",
"(",
"n",
")",
"for",
"n",
"in",
"node",
".",
"body",
")",
"if",
"k",
"]",
"imports",
"=",
"[",
"ast",... | Visit the whole module and add all import at the top level.
>> import numpy.linalg
Becomes
>> import numpy | [
"Visit",
"the",
"whole",
"module",
"and",
"add",
"all",
"import",
"at",
"the",
"top",
"level",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/expand_imports.py#L46-L61 |
237,715 | serge-sans-paille/pythran | pythran/transformations/expand_imports.py | ExpandImports.visit_Name | def visit_Name(self, node):
"""
Replace name with full expanded name.
Examples
--------
>> from numpy.linalg import det
>> det(a)
Becomes
>> numpy.linalg.det(a)
"""
if node.id in self.symbols:
symbol = path_to_node(self.symb... | python | def visit_Name(self, node):
"""
Replace name with full expanded name.
Examples
--------
>> from numpy.linalg import det
>> det(a)
Becomes
>> numpy.linalg.det(a)
"""
if node.id in self.symbols:
symbol = path_to_node(self.symb... | [
"def",
"visit_Name",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"id",
"in",
"self",
".",
"symbols",
":",
"symbol",
"=",
"path_to_node",
"(",
"self",
".",
"symbols",
"[",
"node",
".",
"id",
"]",
")",
"if",
"not",
"getattr",
"(",
"symbol"... | Replace name with full expanded name.
Examples
--------
>> from numpy.linalg import det
>> det(a)
Becomes
>> numpy.linalg.det(a) | [
"Replace",
"name",
"with",
"full",
"expanded",
"name",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/transformations/expand_imports.py#L134-L164 |
237,716 | serge-sans-paille/pythran | pythran/analyses/argument_effects.py | save_function_effect | def save_function_effect(module):
""" Recursively save function effect for pythonic functions. """
for intr in module.values():
if isinstance(intr, dict): # Submodule case
save_function_effect(intr)
else:
fe = FunctionEffects(intr)
IntrinsicArgumentEffects[in... | python | def save_function_effect(module):
""" Recursively save function effect for pythonic functions. """
for intr in module.values():
if isinstance(intr, dict): # Submodule case
save_function_effect(intr)
else:
fe = FunctionEffects(intr)
IntrinsicArgumentEffects[in... | [
"def",
"save_function_effect",
"(",
"module",
")",
":",
"for",
"intr",
"in",
"module",
".",
"values",
"(",
")",
":",
"if",
"isinstance",
"(",
"intr",
",",
"dict",
")",
":",
"# Submodule case",
"save_function_effect",
"(",
"intr",
")",
"else",
":",
"fe",
... | Recursively save function effect for pythonic functions. | [
"Recursively",
"save",
"function",
"effect",
"for",
"pythonic",
"functions",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/argument_effects.py#L35-L44 |
237,717 | serge-sans-paille/pythran | pythran/analyses/argument_effects.py | ArgumentEffects.prepare | def prepare(self, node):
"""
Initialise arguments effects as this analyse is inter-procedural.
Initialisation done for Pythonic functions and default value set for
user defined functions.
"""
super(ArgumentEffects, self).prepare(node)
for n in self.global_declara... | python | def prepare(self, node):
"""
Initialise arguments effects as this analyse is inter-procedural.
Initialisation done for Pythonic functions and default value set for
user defined functions.
"""
super(ArgumentEffects, self).prepare(node)
for n in self.global_declara... | [
"def",
"prepare",
"(",
"self",
",",
"node",
")",
":",
"super",
"(",
"ArgumentEffects",
",",
"self",
")",
".",
"prepare",
"(",
"node",
")",
"for",
"n",
"in",
"self",
".",
"global_declarations",
".",
"values",
"(",
")",
":",
"fe",
"=",
"FunctionEffects",... | Initialise arguments effects as this analyse is inter-procedural.
Initialisation done for Pythonic functions and default value set for
user defined functions. | [
"Initialise",
"arguments",
"effects",
"as",
"this",
"analyse",
"is",
"inter",
"-",
"procedural",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/argument_effects.py#L62-L73 |
237,718 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.process_locals | def process_locals(self, node, node_visited, *skipped):
"""
Declare variable local to node and insert declaration before.
Not possible for function yielding values.
"""
local_vars = self.scope[node].difference(skipped)
local_vars = local_vars.difference(self.openmp_deps)... | python | def process_locals(self, node, node_visited, *skipped):
"""
Declare variable local to node and insert declaration before.
Not possible for function yielding values.
"""
local_vars = self.scope[node].difference(skipped)
local_vars = local_vars.difference(self.openmp_deps)... | [
"def",
"process_locals",
"(",
"self",
",",
"node",
",",
"node_visited",
",",
"*",
"skipped",
")",
":",
"local_vars",
"=",
"self",
".",
"scope",
"[",
"node",
"]",
".",
"difference",
"(",
"skipped",
")",
"local_vars",
"=",
"local_vars",
".",
"difference",
... | Declare variable local to node and insert declaration before.
Not possible for function yielding values. | [
"Declare",
"variable",
"local",
"to",
"node",
"and",
"insert",
"declaration",
"before",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L217-L234 |
237,719 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.process_omp_attachements | def process_omp_attachements(self, node, stmt, index=None):
"""
Add OpenMP pragma on the correct stmt in the correct order.
stmt may be a list. On this case, index have to be specify to add
OpenMP on the correct statement.
"""
omp_directives = metadata.get(node, OMPDirec... | python | def process_omp_attachements(self, node, stmt, index=None):
"""
Add OpenMP pragma on the correct stmt in the correct order.
stmt may be a list. On this case, index have to be specify to add
OpenMP on the correct statement.
"""
omp_directives = metadata.get(node, OMPDirec... | [
"def",
"process_omp_attachements",
"(",
"self",
",",
"node",
",",
"stmt",
",",
"index",
"=",
"None",
")",
":",
"omp_directives",
"=",
"metadata",
".",
"get",
"(",
"node",
",",
"OMPDirective",
")",
"if",
"omp_directives",
":",
"directives",
"=",
"list",
"("... | Add OpenMP pragma on the correct stmt in the correct order.
stmt may be a list. On this case, index have to be specify to add
OpenMP on the correct statement. | [
"Add",
"OpenMP",
"pragma",
"on",
"the",
"correct",
"stmt",
"in",
"the",
"correct",
"order",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L244-L261 |
237,720 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.visit_Assign | def visit_Assign(self, node):
"""
Create Assign node for final Cxx representation.
It tries to handle multi assignment like:
>> a = b = c = 2
If only one local variable is assigned, typing is added:
>> int a = 2;
TODO: Handle case of multi-assignement for som... | python | def visit_Assign(self, node):
"""
Create Assign node for final Cxx representation.
It tries to handle multi assignment like:
>> a = b = c = 2
If only one local variable is assigned, typing is added:
>> int a = 2;
TODO: Handle case of multi-assignement for som... | [
"def",
"visit_Assign",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"all",
"(",
"isinstance",
"(",
"n",
",",
"(",
"ast",
".",
"Name",
",",
"ast",
".",
"Subscript",
")",
")",
"for",
"n",
"in",
"node",
".",
"targets",
")",
":",
"raise",
"Pythra... | Create Assign node for final Cxx representation.
It tries to handle multi assignment like:
>> a = b = c = 2
If only one local variable is assigned, typing is added:
>> int a = 2;
TODO: Handle case of multi-assignement for some local variables.
Finally, process OpenM... | [
"Create",
"Assign",
"node",
"for",
"final",
"Cxx",
"representation",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L392-L443 |
237,721 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.gen_for | def gen_for(self, node, target, local_iter, local_iter_decl, loop_body):
"""
Create For representation on iterator for Cxx generation.
Examples
--------
>> "omp parallel for"
>> for i in xrange(10):
>> ... do things ...
Becomes
>> "omp paral... | python | def gen_for(self, node, target, local_iter, local_iter_decl, loop_body):
"""
Create For representation on iterator for Cxx generation.
Examples
--------
>> "omp parallel for"
>> for i in xrange(10):
>> ... do things ...
Becomes
>> "omp paral... | [
"def",
"gen_for",
"(",
"self",
",",
"node",
",",
"target",
",",
"local_iter",
",",
"local_iter_decl",
",",
"loop_body",
")",
":",
"# Choose target variable for iterator (which is iterator type)",
"local_target",
"=",
"\"__target{0}\"",
".",
"format",
"(",
"id",
"(",
... | Create For representation on iterator for Cxx generation.
Examples
--------
>> "omp parallel for"
>> for i in xrange(10):
>> ... do things ...
Becomes
>> "omp parallel for shared(__iterX)"
>> for(decltype(__iterX)::iterator __targetX = __iterX.begin... | [
"Create",
"For",
"representation",
"on",
"iterator",
"for",
"Cxx",
"generation",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L460-L503 |
237,722 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.handle_real_loop_comparison | def handle_real_loop_comparison(self, args, target, upper_bound):
"""
Handle comparison for real loops.
Add the correct comparison operator if possible.
"""
# order is 1 for increasing loop, -1 for decreasing loop and 0 if it is
# not known at compile time
if len... | python | def handle_real_loop_comparison(self, args, target, upper_bound):
"""
Handle comparison for real loops.
Add the correct comparison operator if possible.
"""
# order is 1 for increasing loop, -1 for decreasing loop and 0 if it is
# not known at compile time
if len... | [
"def",
"handle_real_loop_comparison",
"(",
"self",
",",
"args",
",",
"target",
",",
"upper_bound",
")",
":",
"# order is 1 for increasing loop, -1 for decreasing loop and 0 if it is",
"# not known at compile time",
"if",
"len",
"(",
"args",
")",
"<=",
"2",
":",
"order",
... | Handle comparison for real loops.
Add the correct comparison operator if possible. | [
"Handle",
"comparison",
"for",
"real",
"loops",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L505-L524 |
237,723 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.gen_c_for | def gen_c_for(self, node, local_iter, loop_body):
"""
Create C For representation for Cxx generation.
Examples
--------
>> for i in xrange(10):
>> ... do things ...
Becomes
>> for(long i = 0, __targetX = 10; i < __targetX; i += 1)
>> ...... | python | def gen_c_for(self, node, local_iter, loop_body):
"""
Create C For representation for Cxx generation.
Examples
--------
>> for i in xrange(10):
>> ... do things ...
Becomes
>> for(long i = 0, __targetX = 10; i < __targetX; i += 1)
>> ...... | [
"def",
"gen_c_for",
"(",
"self",
",",
"node",
",",
"local_iter",
",",
"loop_body",
")",
":",
"args",
"=",
"node",
".",
"iter",
".",
"args",
"step",
"=",
"\"1L\"",
"if",
"len",
"(",
"args",
")",
"<=",
"2",
"else",
"self",
".",
"visit",
"(",
"args",
... | Create C For representation for Cxx generation.
Examples
--------
>> for i in xrange(10):
>> ... do things ...
Becomes
>> for(long i = 0, __targetX = 10; i < __targetX; i += 1)
>> ... do things ...
Or
>> for i in xrange(10, 0, -1):
... | [
"Create",
"C",
"For",
"representation",
"for",
"Cxx",
"generation",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L526-L596 |
237,724 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.handle_omp_for | def handle_omp_for(self, node, local_iter):
"""
Fix OpenMP directives on For loops.
Add the target as private variable as a new variable may have been
introduce to handle cxx iterator.
Also, add the iterator as shared variable as all 'parallel for chunck'
have to use th... | python | def handle_omp_for(self, node, local_iter):
"""
Fix OpenMP directives on For loops.
Add the target as private variable as a new variable may have been
introduce to handle cxx iterator.
Also, add the iterator as shared variable as all 'parallel for chunck'
have to use th... | [
"def",
"handle_omp_for",
"(",
"self",
",",
"node",
",",
"local_iter",
")",
":",
"for",
"directive",
"in",
"metadata",
".",
"get",
"(",
"node",
",",
"OMPDirective",
")",
":",
"if",
"any",
"(",
"key",
"in",
"directive",
".",
"s",
"for",
"key",
"in",
"(... | Fix OpenMP directives on For loops.
Add the target as private variable as a new variable may have been
introduce to handle cxx iterator.
Also, add the iterator as shared variable as all 'parallel for chunck'
have to use the same iterator. | [
"Fix",
"OpenMP",
"directives",
"on",
"For",
"loops",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L598-L628 |
237,725 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.can_use_autofor | def can_use_autofor(self, node):
"""
Check if given for Node can use autoFor syntax.
To use auto_for:
- iterator should have local scope
- yield should not be use
- OpenMP pragma should not be use
TODO : Yield should block only if it is use in the fo... | python | def can_use_autofor(self, node):
"""
Check if given for Node can use autoFor syntax.
To use auto_for:
- iterator should have local scope
- yield should not be use
- OpenMP pragma should not be use
TODO : Yield should block only if it is use in the fo... | [
"def",
"can_use_autofor",
"(",
"self",
",",
"node",
")",
":",
"auto_for",
"=",
"(",
"isinstance",
"(",
"node",
".",
"target",
",",
"ast",
".",
"Name",
")",
"and",
"node",
".",
"target",
".",
"id",
"in",
"self",
".",
"scope",
"[",
"node",
"]",
"and"... | Check if given for Node can use autoFor syntax.
To use auto_for:
- iterator should have local scope
- yield should not be use
- OpenMP pragma should not be use
TODO : Yield should block only if it is use in the for loop, not in the
whole function. | [
"Check",
"if",
"given",
"for",
"Node",
"can",
"use",
"autoFor",
"syntax",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L630-L647 |
237,726 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.can_use_c_for | def can_use_c_for(self, node):
"""
Check if a for loop can use classic C syntax.
To use C syntax:
- target should not be assign in the loop
- xrange should be use as iterator
- order have to be known at compile time
"""
assert isinstance(node.... | python | def can_use_c_for(self, node):
"""
Check if a for loop can use classic C syntax.
To use C syntax:
- target should not be assign in the loop
- xrange should be use as iterator
- order have to be known at compile time
"""
assert isinstance(node.... | [
"def",
"can_use_c_for",
"(",
"self",
",",
"node",
")",
":",
"assert",
"isinstance",
"(",
"node",
".",
"target",
",",
"ast",
".",
"Name",
")",
"if",
"sys",
".",
"version_info",
".",
"major",
"==",
"3",
":",
"range_name",
"=",
"'range'",
"else",
":",
"... | Check if a for loop can use classic C syntax.
To use C syntax:
- target should not be assign in the loop
- xrange should be use as iterator
- order have to be known at compile time | [
"Check",
"if",
"a",
"for",
"loop",
"can",
"use",
"classic",
"C",
"syntax",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L649-L682 |
237,727 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.visit_For | def visit_For(self, node):
"""
Create For representation for Cxx generation.
Examples
--------
>> for i in xrange(10):
>> ... work ...
Becomes
>> typename returnable<decltype(__builtin__.xrange(10))>::type __iterX
= __builtin__.xrange(10)... | python | def visit_For(self, node):
"""
Create For representation for Cxx generation.
Examples
--------
>> for i in xrange(10):
>> ... work ...
Becomes
>> typename returnable<decltype(__builtin__.xrange(10))>::type __iterX
= __builtin__.xrange(10)... | [
"def",
"visit_For",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
".",
"target",
",",
"ast",
".",
"Name",
")",
":",
"raise",
"PythranSyntaxError",
"(",
"\"Using something other than an identifier as loop target\"",
",",
"node",
".",... | Create For representation for Cxx generation.
Examples
--------
>> for i in xrange(10):
>> ... work ...
Becomes
>> typename returnable<decltype(__builtin__.xrange(10))>::type __iterX
= __builtin__.xrange(10);
>> ... possible container size reserv... | [
"Create",
"For",
"representation",
"for",
"Cxx",
"generation",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L688-L758 |
237,728 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.visit_While | def visit_While(self, node):
"""
Create While node for Cxx generation.
It is a cxx_loop to handle else clause.
"""
test = self.visit(node.test)
body = [self.visit(n) for n in node.body]
stmt = While(test, Block(body))
return self.process_omp_attachements(... | python | def visit_While(self, node):
"""
Create While node for Cxx generation.
It is a cxx_loop to handle else clause.
"""
test = self.visit(node.test)
body = [self.visit(n) for n in node.body]
stmt = While(test, Block(body))
return self.process_omp_attachements(... | [
"def",
"visit_While",
"(",
"self",
",",
"node",
")",
":",
"test",
"=",
"self",
".",
"visit",
"(",
"node",
".",
"test",
")",
"body",
"=",
"[",
"self",
".",
"visit",
"(",
"n",
")",
"for",
"n",
"in",
"node",
".",
"body",
"]",
"stmt",
"=",
"While",... | Create While node for Cxx generation.
It is a cxx_loop to handle else clause. | [
"Create",
"While",
"node",
"for",
"Cxx",
"generation",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L761-L770 |
237,729 | serge-sans-paille/pythran | pythran/backend.py | CxxFunction.visit_Break | def visit_Break(self, _):
"""
Generate break statement in most case and goto for orelse clause.
See Also : cxx_loop
"""
if self.break_handlers and self.break_handlers[-1]:
return Statement("goto {0}".format(self.break_handlers[-1]))
else:
return S... | python | def visit_Break(self, _):
"""
Generate break statement in most case and goto for orelse clause.
See Also : cxx_loop
"""
if self.break_handlers and self.break_handlers[-1]:
return Statement("goto {0}".format(self.break_handlers[-1]))
else:
return S... | [
"def",
"visit_Break",
"(",
"self",
",",
"_",
")",
":",
"if",
"self",
".",
"break_handlers",
"and",
"self",
".",
"break_handlers",
"[",
"-",
"1",
"]",
":",
"return",
"Statement",
"(",
"\"goto {0}\"",
".",
"format",
"(",
"self",
".",
"break_handlers",
"[",... | Generate break statement in most case and goto for orelse clause.
See Also : cxx_loop | [
"Generate",
"break",
"statement",
"in",
"most",
"case",
"and",
"goto",
"for",
"orelse",
"clause",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L827-L836 |
237,730 | serge-sans-paille/pythran | pythran/backend.py | Cxx.visit_Module | def visit_Module(self, node):
""" Build a compilation unit. """
# build all types
deps = sorted(self.dependencies)
headers = [Include(os.path.join("pythonic", "include", *t) + ".hpp")
for t in deps]
headers += [Include(os.path.join("pythonic", *t) + ".hpp")
... | python | def visit_Module(self, node):
""" Build a compilation unit. """
# build all types
deps = sorted(self.dependencies)
headers = [Include(os.path.join("pythonic", "include", *t) + ".hpp")
for t in deps]
headers += [Include(os.path.join("pythonic", *t) + ".hpp")
... | [
"def",
"visit_Module",
"(",
"self",
",",
"node",
")",
":",
"# build all types",
"deps",
"=",
"sorted",
"(",
"self",
".",
"dependencies",
")",
"headers",
"=",
"[",
"Include",
"(",
"os",
".",
"path",
".",
"join",
"(",
"\"pythonic\"",
",",
"\"include\"",
",... | Build a compilation unit. | [
"Build",
"a",
"compilation",
"unit",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/backend.py#L1275-L1289 |
237,731 | serge-sans-paille/pythran | pythran/middlend.py | refine | def refine(pm, node, optimizations):
""" Refine node in place until it matches pythran's expectations. """
# Sanitize input
pm.apply(ExpandGlobals, node)
pm.apply(ExpandImportAll, node)
pm.apply(NormalizeTuples, node)
pm.apply(ExpandBuiltins, node)
pm.apply(ExpandImports, node)
pm.apply(... | python | def refine(pm, node, optimizations):
""" Refine node in place until it matches pythran's expectations. """
# Sanitize input
pm.apply(ExpandGlobals, node)
pm.apply(ExpandImportAll, node)
pm.apply(NormalizeTuples, node)
pm.apply(ExpandBuiltins, node)
pm.apply(ExpandImports, node)
pm.apply(... | [
"def",
"refine",
"(",
"pm",
",",
"node",
",",
"optimizations",
")",
":",
"# Sanitize input",
"pm",
".",
"apply",
"(",
"ExpandGlobals",
",",
"node",
")",
"pm",
".",
"apply",
"(",
"ExpandImportAll",
",",
"node",
")",
"pm",
".",
"apply",
"(",
"NormalizeTupl... | Refine node in place until it matches pythran's expectations. | [
"Refine",
"node",
"in",
"place",
"until",
"it",
"matches",
"pythran",
"s",
"expectations",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/middlend.py#L16-L55 |
237,732 | serge-sans-paille/pythran | pythran/analyses/global_effects.py | GlobalEffects.prepare | def prepare(self, node):
"""
Initialise globals effects as this analyse is inter-procedural.
Initialisation done for Pythonic functions and default value set for
user defined functions.
"""
super(GlobalEffects, self).prepare(node)
def register_node(module):
... | python | def prepare(self, node):
"""
Initialise globals effects as this analyse is inter-procedural.
Initialisation done for Pythonic functions and default value set for
user defined functions.
"""
super(GlobalEffects, self).prepare(node)
def register_node(module):
... | [
"def",
"prepare",
"(",
"self",
",",
"node",
")",
":",
"super",
"(",
"GlobalEffects",
",",
"self",
")",
".",
"prepare",
"(",
"node",
")",
"def",
"register_node",
"(",
"module",
")",
":",
"\"\"\" Recursively save globals effect for all functions. \"\"\"",
"for",
"... | Initialise globals effects as this analyse is inter-procedural.
Initialisation done for Pythonic functions and default value set for
user defined functions. | [
"Initialise",
"globals",
"effects",
"as",
"this",
"analyse",
"is",
"inter",
"-",
"procedural",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/global_effects.py#L43-L68 |
237,733 | serge-sans-paille/pythran | pythran/types/types.py | Types.prepare | def prepare(self, node):
"""
Initialise values to prepare typing computation.
Reorder functions to avoid dependencies issues and prepare typing
computation setting typing values for Pythonic functions.
"""
def register(name, module):
""" Recursively save fun... | python | def prepare(self, node):
"""
Initialise values to prepare typing computation.
Reorder functions to avoid dependencies issues and prepare typing
computation setting typing values for Pythonic functions.
"""
def register(name, module):
""" Recursively save fun... | [
"def",
"prepare",
"(",
"self",
",",
"node",
")",
":",
"def",
"register",
"(",
"name",
",",
"module",
")",
":",
"\"\"\" Recursively save function typing and combiners for Pythonic.\"\"\"",
"for",
"fname",
",",
"function",
"in",
"module",
".",
"items",
"(",
")",
"... | Initialise values to prepare typing computation.
Reorder functions to avoid dependencies issues and prepare typing
computation setting typing values for Pythonic functions. | [
"Initialise",
"values",
"to",
"prepare",
"typing",
"computation",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L75-L97 |
237,734 | serge-sans-paille/pythran | pythran/types/types.py | Types.register | def register(self, ptype):
"""register ptype as a local typedef"""
# Too many of them leads to memory burst
if len(self.typedefs) < cfg.getint('typing', 'max_combiner'):
self.typedefs.append(ptype)
return True
return False | python | def register(self, ptype):
"""register ptype as a local typedef"""
# Too many of them leads to memory burst
if len(self.typedefs) < cfg.getint('typing', 'max_combiner'):
self.typedefs.append(ptype)
return True
return False | [
"def",
"register",
"(",
"self",
",",
"ptype",
")",
":",
"# Too many of them leads to memory burst",
"if",
"len",
"(",
"self",
".",
"typedefs",
")",
"<",
"cfg",
".",
"getint",
"(",
"'typing'",
",",
"'max_combiner'",
")",
":",
"self",
".",
"typedefs",
".",
"... | register ptype as a local typedef | [
"register",
"ptype",
"as",
"a",
"local",
"typedef"
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L106-L112 |
237,735 | serge-sans-paille/pythran | pythran/types/types.py | Types.isargument | def isargument(self, node):
""" checks whether node aliases to a parameter."""
try:
node_id, _ = self.node_to_id(node)
return (node_id in self.name_to_nodes and
any([isinstance(n, ast.Name) and
isinstance(n.ctx, ast.Param)
... | python | def isargument(self, node):
""" checks whether node aliases to a parameter."""
try:
node_id, _ = self.node_to_id(node)
return (node_id in self.name_to_nodes and
any([isinstance(n, ast.Name) and
isinstance(n.ctx, ast.Param)
... | [
"def",
"isargument",
"(",
"self",
",",
"node",
")",
":",
"try",
":",
"node_id",
",",
"_",
"=",
"self",
".",
"node_to_id",
"(",
"node",
")",
"return",
"(",
"node_id",
"in",
"self",
".",
"name_to_nodes",
"and",
"any",
"(",
"[",
"isinstance",
"(",
"n",
... | checks whether node aliases to a parameter. | [
"checks",
"whether",
"node",
"aliases",
"to",
"a",
"parameter",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L133-L142 |
237,736 | serge-sans-paille/pythran | pythran/types/types.py | Types.combine | def combine(self, node, othernode, op=None, unary_op=None, register=False,
aliasing_type=False):
"""
Change `node` typing with combination of `node` and `othernode`.
Parameters
----------
aliasing_type : bool
All node aliasing to `node` have to be upd... | python | def combine(self, node, othernode, op=None, unary_op=None, register=False,
aliasing_type=False):
"""
Change `node` typing with combination of `node` and `othernode`.
Parameters
----------
aliasing_type : bool
All node aliasing to `node` have to be upd... | [
"def",
"combine",
"(",
"self",
",",
"node",
",",
"othernode",
",",
"op",
"=",
"None",
",",
"unary_op",
"=",
"None",
",",
"register",
"=",
"False",
",",
"aliasing_type",
"=",
"False",
")",
":",
"if",
"self",
".",
"result",
"[",
"othernode",
"]",
"is",... | Change `node` typing with combination of `node` and `othernode`.
Parameters
----------
aliasing_type : bool
All node aliasing to `node` have to be updated too. | [
"Change",
"node",
"typing",
"with",
"combination",
"of",
"node",
"and",
"othernode",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L144-L167 |
237,737 | serge-sans-paille/pythran | pythran/types/types.py | Types.visit_Return | def visit_Return(self, node):
""" Compute return type and merges with others possible return type."""
self.generic_visit(node)
# No merge are done if the function is a generator.
if not self.yield_points:
assert node.value, "Values were added in each return statement."
... | python | def visit_Return(self, node):
""" Compute return type and merges with others possible return type."""
self.generic_visit(node)
# No merge are done if the function is a generator.
if not self.yield_points:
assert node.value, "Values were added in each return statement."
... | [
"def",
"visit_Return",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"generic_visit",
"(",
"node",
")",
"# No merge are done if the function is a generator.",
"if",
"not",
"self",
".",
"yield_points",
":",
"assert",
"node",
".",
"value",
",",
"\"Values were add... | Compute return type and merges with others possible return type. | [
"Compute",
"return",
"type",
"and",
"merges",
"with",
"others",
"possible",
"return",
"type",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L293-L299 |
237,738 | serge-sans-paille/pythran | pythran/types/types.py | Types.visit_Yield | def visit_Yield(self, node):
""" Compute yield type and merges it with others yield type. """
self.generic_visit(node)
self.combine(self.current, node.value) | python | def visit_Yield(self, node):
""" Compute yield type and merges it with others yield type. """
self.generic_visit(node)
self.combine(self.current, node.value) | [
"def",
"visit_Yield",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"generic_visit",
"(",
"node",
")",
"self",
".",
"combine",
"(",
"self",
".",
"current",
",",
"node",
".",
"value",
")"
] | Compute yield type and merges it with others yield type. | [
"Compute",
"yield",
"type",
"and",
"merges",
"it",
"with",
"others",
"yield",
"type",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L301-L304 |
237,739 | serge-sans-paille/pythran | pythran/types/types.py | Types.visit_BoolOp | def visit_BoolOp(self, node):
"""
Merge BoolOp operand type.
BoolOp are "and" and "or" and may return any of these results so all
operands should have the combinable type.
"""
# Visit subnodes
self.generic_visit(node)
# Merge all operands types.
[... | python | def visit_BoolOp(self, node):
"""
Merge BoolOp operand type.
BoolOp are "and" and "or" and may return any of these results so all
operands should have the combinable type.
"""
# Visit subnodes
self.generic_visit(node)
# Merge all operands types.
[... | [
"def",
"visit_BoolOp",
"(",
"self",
",",
"node",
")",
":",
"# Visit subnodes",
"self",
".",
"generic_visit",
"(",
"node",
")",
"# Merge all operands types.",
"[",
"self",
".",
"combine",
"(",
"node",
",",
"value",
")",
"for",
"value",
"in",
"node",
".",
"v... | Merge BoolOp operand type.
BoolOp are "and" and "or" and may return any of these results so all
operands should have the combinable type. | [
"Merge",
"BoolOp",
"operand",
"type",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L349-L359 |
237,740 | serge-sans-paille/pythran | pythran/types/types.py | Types.visit_Num | def visit_Num(self, node):
"""
Set type for number.
It could be int, long or float so we use the default python to pythonic
type converter.
"""
ty = type(node.n)
sty = pytype_to_ctype(ty)
if node in self.immediates:
sty = "std::integral_consta... | python | def visit_Num(self, node):
"""
Set type for number.
It could be int, long or float so we use the default python to pythonic
type converter.
"""
ty = type(node.n)
sty = pytype_to_ctype(ty)
if node in self.immediates:
sty = "std::integral_consta... | [
"def",
"visit_Num",
"(",
"self",
",",
"node",
")",
":",
"ty",
"=",
"type",
"(",
"node",
".",
"n",
")",
"sty",
"=",
"pytype_to_ctype",
"(",
"ty",
")",
"if",
"node",
"in",
"self",
".",
"immediates",
":",
"sty",
"=",
"\"std::integral_constant<%s, %s>\"",
... | Set type for number.
It could be int, long or float so we use the default python to pythonic
type converter. | [
"Set",
"type",
"for",
"number",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L450-L462 |
237,741 | serge-sans-paille/pythran | pythran/types/types.py | Types.visit_Str | def visit_Str(self, node):
""" Set the pythonic string type. """
self.result[node] = self.builder.NamedType(pytype_to_ctype(str)) | python | def visit_Str(self, node):
""" Set the pythonic string type. """
self.result[node] = self.builder.NamedType(pytype_to_ctype(str)) | [
"def",
"visit_Str",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"result",
"[",
"node",
"]",
"=",
"self",
".",
"builder",
".",
"NamedType",
"(",
"pytype_to_ctype",
"(",
"str",
")",
")"
] | Set the pythonic string type. | [
"Set",
"the",
"pythonic",
"string",
"type",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L464-L466 |
237,742 | serge-sans-paille/pythran | pythran/types/types.py | Types.visit_Attribute | def visit_Attribute(self, node):
""" Compute typing for an attribute node. """
obj, path = attr_to_path(node)
# If no type is given, use a decltype
if obj.isliteral():
typename = pytype_to_ctype(obj.signature)
self.result[node] = self.builder.NamedType(typename)
... | python | def visit_Attribute(self, node):
""" Compute typing for an attribute node. """
obj, path = attr_to_path(node)
# If no type is given, use a decltype
if obj.isliteral():
typename = pytype_to_ctype(obj.signature)
self.result[node] = self.builder.NamedType(typename)
... | [
"def",
"visit_Attribute",
"(",
"self",
",",
"node",
")",
":",
"obj",
",",
"path",
"=",
"attr_to_path",
"(",
"node",
")",
"# If no type is given, use a decltype",
"if",
"obj",
".",
"isliteral",
"(",
")",
":",
"typename",
"=",
"pytype_to_ctype",
"(",
"obj",
".... | Compute typing for an attribute node. | [
"Compute",
"typing",
"for",
"an",
"attribute",
"node",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L468-L476 |
237,743 | serge-sans-paille/pythran | pythran/types/types.py | Types.visit_Slice | def visit_Slice(self, node):
"""
Set slicing type using continuous information if provided.
Also visit subnodes as they may contains relevant typing information.
"""
self.generic_visit(node)
if node.step is None or (isinstance(node.step, ast.Num) and
... | python | def visit_Slice(self, node):
"""
Set slicing type using continuous information if provided.
Also visit subnodes as they may contains relevant typing information.
"""
self.generic_visit(node)
if node.step is None or (isinstance(node.step, ast.Num) and
... | [
"def",
"visit_Slice",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"generic_visit",
"(",
"node",
")",
"if",
"node",
".",
"step",
"is",
"None",
"or",
"(",
"isinstance",
"(",
"node",
".",
"step",
",",
"ast",
".",
"Num",
")",
"and",
"node",
".",
... | Set slicing type using continuous information if provided.
Also visit subnodes as they may contains relevant typing information. | [
"Set",
"slicing",
"type",
"using",
"continuous",
"information",
"if",
"provided",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/types/types.py#L478-L491 |
237,744 | serge-sans-paille/pythran | omp/__init__.py | OpenMP.init_not_msvc | def init_not_msvc(self):
""" Find OpenMP library and try to load if using ctype interface. """
# find_library() does not search automatically LD_LIBRARY_PATH
paths = os.environ.get('LD_LIBRARY_PATH', '').split(':')
for gomp in ('libgomp.so', 'libgomp.dylib'):
if cxx is None:
... | python | def init_not_msvc(self):
""" Find OpenMP library and try to load if using ctype interface. """
# find_library() does not search automatically LD_LIBRARY_PATH
paths = os.environ.get('LD_LIBRARY_PATH', '').split(':')
for gomp in ('libgomp.so', 'libgomp.dylib'):
if cxx is None:
... | [
"def",
"init_not_msvc",
"(",
"self",
")",
":",
"# find_library() does not search automatically LD_LIBRARY_PATH",
"paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'LD_LIBRARY_PATH'",
",",
"''",
")",
".",
"split",
"(",
"':'",
")",
"for",
"gomp",
"in",
"(",
... | Find OpenMP library and try to load if using ctype interface. | [
"Find",
"OpenMP",
"library",
"and",
"try",
"to",
"load",
"if",
"using",
"ctype",
"interface",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/omp/__init__.py#L44-L79 |
237,745 | serge-sans-paille/pythran | pythran/analyses/inlinable.py | Inlinable.visit_FunctionDef | def visit_FunctionDef(self, node):
""" Determine this function definition can be inlined. """
if (len(node.body) == 1 and
isinstance(node.body[0], (ast.Call, ast.Return))):
ids = self.gather(Identifiers, node.body[0])
# FIXME : It mark "not inlinable" def foo(foo)... | python | def visit_FunctionDef(self, node):
""" Determine this function definition can be inlined. """
if (len(node.body) == 1 and
isinstance(node.body[0], (ast.Call, ast.Return))):
ids = self.gather(Identifiers, node.body[0])
# FIXME : It mark "not inlinable" def foo(foo)... | [
"def",
"visit_FunctionDef",
"(",
"self",
",",
"node",
")",
":",
"if",
"(",
"len",
"(",
"node",
".",
"body",
")",
"==",
"1",
"and",
"isinstance",
"(",
"node",
".",
"body",
"[",
"0",
"]",
",",
"(",
"ast",
".",
"Call",
",",
"ast",
".",
"Return",
"... | Determine this function definition can be inlined. | [
"Determine",
"this",
"function",
"definition",
"can",
"be",
"inlined",
"."
] | 7e1b5af2dddfabc50bd2a977f0178be269b349b5 | https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/analyses/inlinable.py#L22-L29 |
237,746 | 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 |
237,747 | 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 |
237,748 | 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 |
237,749 | 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 |
237,750 | 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",
")",
":",
"# Ensure there are no nested functions.",
"assert",
"self",
".",
"current_function",
"is",
"None",
"self",
".",
"current_function",
"=",
"node",
"self",
".",
"naming",
"=",
"dict",
"(",
")",
"self"... | 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 |
237,751 | 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",
":",
"# Yielding function can't return values",
"return",
"for",
"dep_set",
"in",
"self",
".",
"visit",
"(",
"node",
".",
"value",
")",
":",
"if",
"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 |
237,752 | 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 |
237,753 | 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 |
237,754 | 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 |
237,755 | 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 |
237,756 | 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 |
237,757 | 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 |
237,758 | 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 |
237,759 | 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 |
237,760 | 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 |
237,761 | 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 |
237,762 | 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",
"(",
")",
"# Gather top level assigned variables.",
"for",
"stmt",
"in",
"node",
".",
"body",
":",
"if",
"isinstance",
"(",
"stmt",
",",... | 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 |
237,763 | 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 |
237,764 | 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 |
237,765 | 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 |
237,766 | 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",
")",
"# Only attributes function can be Pythonic and should be normalized",
"if",
"isinstance",
"(",
"node",
".",
"func",
",",
"ast",
".",
"Attribute",... | 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 |
237,767 | 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 each function",
"for",
"signatures",
"in",
"specs",
".",
"functions",
".",
"values",
"(",
")",
":",
"# for each signature",
"for",
"signature",
"in",
"signatures",... | 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 |
237,768 | 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 |
237,769 | 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 |
237,770 | 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",
")",
"# front end",
"ir",
",",
"renamings",
",",
"docstr... | 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 |
237,771 | 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 |
237,772 | 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",
"(",
"p... | 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 |
237,773 | 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",
":",
"# derive modul... | 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 |
237,774 | 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",
")",
":",
"\"\"\"\n Wrap comprehension content in all possibles if clauses.\n\n Examples\n --------\n >> [i for i in xrange(2) if i < 3 if 0... | 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 |
237,775 | 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 |
237,776 | 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",
"(",
")",
":",
"\"\"\" Iterator generating lines for struct definition. \"\"\"",
"decl",
"=",
"\"struct \"",
"if",
"self",
".",
"tpname",
"is",
"not",
"None",
":",
"decl",
"+=",
"self",
".",
"tpname... | 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 |
237,777 | 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 |
237,778 | 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 |
237,779 | 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 |
237,780 | 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 |
237,781 | 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 |
237,782 | 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",
"=",
"(",
")",
"# true branch",
"for",
"n",
"in",
"node",
".",
"body",
":",
"self",
".",
"result",
".",
"add_node",
"(",
"n",
")",
"for",
"curr"... | 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 |
237,783 | 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 |
237,784 | 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 |
237,785 | 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 |
237,786 | 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 |
237,787 | 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 |
237,788 | 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 |
237,789 | 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 |
237,790 | 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",
")",
":",
"# visit once to gather newly declared vars",
"for",
"stmt",
"in",
"node",
".",
"body",
":",
"self",
".",
"visit",
"(",
"stmt",
")",
"# freeze current state",
"old_range",
"=",
... | 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 |
237,791 | 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 |
237,792 | 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 |
237,793 | 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 |
237,794 | 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 |
237,795 | 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 |
237,796 | 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 |
237,797 | 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 |
237,798 | 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 |
237,799 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.