Commit 17da082e authored by Vitja Makarov's avatar Vitja Makarov

Merge remote branch 'upstream/master'

parents 2a9ed746 50570112
...@@ -168,7 +168,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -168,7 +168,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
return env.qualified_name.replace(".", "__") return env.qualified_name.replace(".", "__")
def generate_api_code(self, env, result): def generate_api_code(self, env, result):
def api_entries(entries, pxd=1): def api_entries(entries, pxd=0):
return [entry for entry in entries return [entry for entry in entries
if entry.api or (pxd and entry.defined_in_pxd)] if entry.api or (pxd and entry.defined_in_pxd)]
api_vars = api_entries(env.var_entries) api_vars = api_entries(env.var_entries)
......
...@@ -1257,9 +1257,10 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1257,9 +1257,10 @@ class FuncDefNode(StatNode, BlockNode):
preprocessor_guard = None preprocessor_guard = None
profile = code.globalstate.directives['profile'] profile = code.globalstate.directives['profile']
if profile and lenv.nogil:
warning(self.pos, "Cannot profile nogil function.", 1)
profile = False
if profile: if profile:
if lenv.nogil:
error(self.pos, "Cannot profile nogil function.")
code.globalstate.use_utility_code(profile_utility_code) code.globalstate.use_utility_code(profile_utility_code)
# Generate C code for header and body of function # Generate C code for header and body of function
......
...@@ -320,6 +320,20 @@ class PostParse(ScopeTrackingTransform): ...@@ -320,6 +320,20 @@ class PostParse(ScopeTrackingTransform):
return assign_node return assign_node
def _flatten_sequence(self, seq, result):
for arg in seq.args:
if arg.is_sequence_constructor:
self._flatten_sequence(arg, result)
else:
result.append(arg)
return result
def visit_DelStatNode(self, node):
self.visitchildren(node)
node.args = self._flatten_sequence(node, [])
return node
def eliminate_rhs_duplicates(expr_list_list, ref_node_sequence): def eliminate_rhs_duplicates(expr_list_list, ref_node_sequence):
"""Replace rhs items by LetRefNodes if they appear more than once. """Replace rhs items by LetRefNodes if they appear more than once.
Creates a sequence of LetRefNodes that set up the required temps Creates a sequence of LetRefNodes that set up the required temps
......
...@@ -87,3 +87,12 @@ def del_local(a): ...@@ -87,3 +87,12 @@ def del_local(a):
""" """
del a del a
assert a is None # Until we have unbound locals... assert a is None # Until we have unbound locals...
def del_seq(a, b, c):
"""
>>> del_seq(1, 2, 3)
"""
del a, (b, c)
assert a is None # Until we have unbound locals...
assert b is None # Until we have unbound locals...
assert c is None # Until we have unbound locals...
...@@ -20,6 +20,23 @@ __doc__ = u""" ...@@ -20,6 +20,23 @@ __doc__ = u"""
KeyError: 'f_noprof' KeyError: 'f_noprof'
>>> short_stats['f_raise'] >>> short_stats['f_raise']
100 100
>>> short_stats['withgil_prof']
100
>>> short_stats['withgil_noprof']
Traceback (most recent call last):
...
KeyError: 'withgil_noprof'
>>> short_stats['nogil_prof']
Traceback (most recent call last):
...
KeyError: 'nogil_prof'
>>> short_stats['nogil_noprof']
Traceback (most recent call last):
...
KeyError: 'nogil_noprof'
>>> try: >>> try:
... os.unlink(statsfile) ... os.unlink(statsfile)
... except: ... except:
...@@ -43,6 +60,10 @@ def test_profile(long N): ...@@ -43,6 +60,10 @@ def test_profile(long N):
n += f_inline(i) n += f_inline(i)
n += f_inline_prof(i) n += f_inline_prof(i)
n += f_noprof(i) n += f_noprof(i)
n += nogil_noprof(i)
n += nogil_prof(i)
n += withgil_noprof(i)
n += withgil_prof(i)
try: try:
n += f_raise(i+2) n += f_raise(i+2)
except RuntimeError: except RuntimeError:
...@@ -68,3 +89,18 @@ cdef int f_noprof(long a): ...@@ -68,3 +89,18 @@ cdef int f_noprof(long a):
cdef long f_raise(long) except -2: cdef long f_raise(long) except -2:
raise RuntimeError raise RuntimeError
@cython.profile(False)
cdef int withgil_noprof(long a) with gil:
return (a)
@cython.profile(True)
cdef int withgil_prof(long a) with gil:
return (a)
@cython.profile(False)
cdef int nogil_noprof(long a) nogil:
return a
@cython.profile(True)
cdef int nogil_prof(long a) nogil:
return a
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment