Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
e0fc3131
Commit
e0fc3131
authored
Apr 07, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable type inference in generators (but keep it disabled for variables in other closures)
parent
7386ad24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
Cython/Compiler/TypeInference.py
Cython/Compiler/TypeInference.py
+6
-2
tests/bugs.txt
tests/bugs.txt
+0
-1
No files found.
Cython/Compiler/TypeInference.py
View file @
e0fc3131
...
@@ -221,9 +221,9 @@ class SimpleAssignmentTypeInferer(object):
...
@@ -221,9 +221,9 @@ class SimpleAssignmentTypeInferer(object):
# TODO: Implement a real type inference algorithm.
# TODO: Implement a real type inference algorithm.
# (Something more powerful than just extending this one...)
# (Something more powerful than just extending this one...)
def
infer_types
(
self
,
scope
):
def
infer_types
(
self
,
scope
):
closure_or_inner
=
scope
.
is_closure_scope
or
(
scope
.
outer_scope
and
scope
.
outer_scope
.
is_closure_scope
)
enabled
=
scope
.
directives
[
'infer_types'
]
enabled
=
not
closure_or_inner
and
scope
.
directives
[
'infer_types'
]
verbose
=
scope
.
directives
[
'infer_types.verbose'
]
verbose
=
scope
.
directives
[
'infer_types.verbose'
]
if
enabled
==
True
:
if
enabled
==
True
:
spanning_type
=
aggressive_spanning_type
spanning_type
=
aggressive_spanning_type
elif
enabled
is
None
:
# safe mode
elif
enabled
is
None
:
# safe mode
...
@@ -239,6 +239,10 @@ class SimpleAssignmentTypeInferer(object):
...
@@ -239,6 +239,10 @@ class SimpleAssignmentTypeInferer(object):
ready_to_infer
=
[]
ready_to_infer
=
[]
for
name
,
entry
in
scope
.
entries
.
items
():
for
name
,
entry
in
scope
.
entries
.
items
():
if
entry
.
type
is
unspecified_type
:
if
entry
.
type
is
unspecified_type
:
if
entry
.
in_closure
:
# cross-closure type inference is not currently supported
entry
.
type
=
py_object_type
continue
all
=
set
()
all
=
set
()
for
expr
in
entry
.
assignments
:
for
expr
in
entry
.
assignments
:
all
.
update
(
expr
.
type_dependencies
(
scope
))
all
.
update
(
expr
.
type_dependencies
(
scope
))
...
...
tests/bugs.txt
View file @
e0fc3131
...
@@ -18,7 +18,6 @@ genexpr_iterable_lookup_T600
...
@@ -18,7 +18,6 @@ genexpr_iterable_lookup_T600
for_from_pyvar_loop_T601
for_from_pyvar_loop_T601
decorators_T593
decorators_T593
temp_sideeffects_T654
temp_sideeffects_T654
generator_type_inference
# CPython regression tests that don't current work:
# CPython regression tests that don't current work:
pyregr.test_threadsignals
pyregr.test_threadsignals
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment