summaryrefslogtreecommitdiff
path: root/Cython/Compiler/Nodes.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-11-05 11:57:40 +0100
committerStefan Behnel <stefan_ml@behnel.de>2017-11-05 12:00:02 +0100
commit65b17751ca7e15d68d6d18ee0c55afadf5fc77fb (patch)
tree570aac3cf8e6f65410a59da49c0f9b7010b4b491 /Cython/Compiler/Nodes.py
parent9a33e34bd6e0c5dfb5ce6e18ec640a9129f1f0b0 (diff)
downloadcython-65b17751ca7e15d68d6d18ee0c55afadf5fc77fb.tar.gz
Optimise iteration over containers declared with a "Dict[...]" type annotation.
See #1979.
Diffstat (limited to 'Cython/Compiler/Nodes.py')
-rw-r--r--Cython/Compiler/Nodes.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py
index e0fb4b5bc..7ebaa7d0a 100644
--- a/Cython/Compiler/Nodes.py
+++ b/Cython/Compiler/Nodes.py
@@ -2159,7 +2159,10 @@ class FuncDefNode(StatNode, BlockNode):
error(arg.pos, "Invalid use of 'void'")
elif not arg.type.is_complete() and not (arg.type.is_array or arg.type.is_memoryviewslice):
error(arg.pos, "Argument type '%s' is incomplete" % arg.type)
- return env.declare_arg(arg.name, arg.type, arg.pos)
+ entry = env.declare_arg(arg.name, arg.type, arg.pos)
+ if arg.annotation:
+ entry.annotation = arg.annotation
+ return entry
def generate_arg_type_test(self, arg, code):
# Generate type test for one argument.
@@ -2775,6 +2778,7 @@ class DefNode(FuncDefNode):
name_declarator, type = formal_arg.analyse(scope, nonempty=1)
cfunc_args.append(PyrexTypes.CFuncTypeArg(name=name_declarator.name,
cname=None,
+ annotation=formal_arg.annotation,
type=py_object_type,
pos=formal_arg.pos))
cfunc_type = PyrexTypes.CFuncType(return_type=py_object_type,