Commit 3ed359ce authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Cython optimizations regarding embedding signatures

parent e04c414e
...@@ -89,6 +89,14 @@ class EmbedSignature(CythonTransform): ...@@ -89,6 +89,14 @@ class EmbedSignature(CythonTransform):
else: else:
return signature return signature
def __call__(self, node):
if not Options.docstrings:
return node
else:
self.visitchildren(node)
return node
def visit_ClassDefNode(self, node): def visit_ClassDefNode(self, node):
oldincls = self.is_in_class oldincls = self.is_in_class
oldname = self.class_name oldname = self.class_name
...@@ -105,6 +113,9 @@ class EmbedSignature(CythonTransform): ...@@ -105,6 +113,9 @@ class EmbedSignature(CythonTransform):
return node return node
def visit_FuncDefNode(self, node): def visit_FuncDefNode(self, node):
if not node.options['embedsignature']:
return node
signature = None signature = None
if type(node) is DefNode: # def FOO(...): if type(node) is DefNode: # def FOO(...):
special_method = (self.is_in_class and \ special_method = (self.is_in_class and \
...@@ -126,7 +137,6 @@ class EmbedSignature(CythonTransform): ...@@ -126,7 +137,6 @@ class EmbedSignature(CythonTransform):
else: # should not fall here ... else: # should not fall here ...
assert False assert False
if signature: if signature:
if Options.docstrings and node.options['embedsignature']: new_doc = self._embed_signature(signature, node.doc)
new_doc = self._embed_signature(signature, node.doc) node.doc = EncodedString(new_doc) # XXX
node.doc = EncodedString(new_doc) # XXX
return node return node
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