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
e023f0e3
Commit
e023f0e3
authored
Oct 09, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Defer loading cython scope until necessary
parent
602b8cff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
14 deletions
+26
-14
Cython/Compiler/CythonScope.py
Cython/Compiler/CythonScope.py
+24
-11
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+1
-3
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+1
-0
No files found.
Cython/Compiler/CythonScope.py
View file @
e023f0e3
...
@@ -9,6 +9,7 @@ import MemoryView
...
@@ -9,6 +9,7 @@ import MemoryView
class
CythonScope
(
ModuleScope
):
class
CythonScope
(
ModuleScope
):
is_cython_builtin
=
1
is_cython_builtin
=
1
_cythonscope_initialized
=
False
def
__init__
(
self
,
context
):
def
__init__
(
self
,
context
):
ModuleScope
.
__init__
(
self
,
u'cython'
,
None
,
None
)
ModuleScope
.
__init__
(
self
,
u'cython'
,
None
,
None
)
...
@@ -23,11 +24,26 @@ class CythonScope(ModuleScope):
...
@@ -23,11 +24,26 @@ class CythonScope(ModuleScope):
if
type
:
if
type
:
return
type
return
type
return
super
(
CythonScope
,
self
).
lookup_type
(
name
)
def
lookup
(
self
,
name
):
entry
=
super
(
CythonScope
,
self
).
lookup
(
name
)
if
entry
is
None
and
not
self
.
_cythonscope_initialized
:
self
.
load_cythonscope
()
entry
=
super
(
CythonScope
,
self
).
lookup
(
name
)
return
entry
def
find_module
(
self
,
module_name
,
pos
):
def
find_module
(
self
,
module_name
,
pos
):
error
(
"cython.%s is not available"
%
module_name
,
pos
)
error
(
"cython.%s is not available"
%
module_name
,
pos
)
def
find_submodule
(
self
,
module_name
):
def
find_submodule
(
self
,
module_name
):
entry
=
self
.
entries
.
get
(
module_name
,
None
)
entry
=
self
.
entries
.
get
(
module_name
,
None
)
if
not
entry
:
self
.
load_cythonscope
()
entry
=
self
.
entries
.
get
(
module_name
,
None
)
if
entry
and
entry
.
as_module
:
if
entry
and
entry
.
as_module
:
return
entry
.
as_module
return
entry
.
as_module
else
:
else
:
...
@@ -68,13 +84,15 @@ class CythonScope(ModuleScope):
...
@@ -68,13 +84,15 @@ class CythonScope(ModuleScope):
defining
=
1
,
defining
=
1
,
cname
=
'PyObject_TypeCheck'
)
cname
=
'PyObject_TypeCheck'
)
# self.test_cythonscope()
def
load_cythonscope
(
self
):
def
test_cythonscope
(
self
):
"""
"""
Creates some entries for testing purposes and entries for
Creates some entries for testing purposes and entries for
cython.array() and for cython.view.*.
cython.array() and for cython.view.*.
"""
"""
if
self
.
_cythonscope_initialized
:
return
self
.
_cythonscope_initialized
=
True
cython_testscope_utility_code
.
declare_in_scope
(
cython_testscope_utility_code
.
declare_in_scope
(
self
,
cython_scope
=
self
)
self
,
cython_scope
=
self
)
cython_test_extclass_utility_code
.
declare_in_scope
(
cython_test_extclass_utility_code
.
declare_in_scope
(
...
@@ -100,16 +118,11 @@ class CythonScope(ModuleScope):
...
@@ -100,16 +118,11 @@ class CythonScope(ModuleScope):
# MemoryView.memview_fromslice_utility_code.declare_in_scope(viewscope)
# MemoryView.memview_fromslice_utility_code.declare_in_scope(viewscope)
def
create_cython_scope
(
context
,
create_testscope
):
def
create_cython_scope
(
context
):
# One could in fact probably make it a singleton,
# One could in fact probably make it a singleton,
# but not sure yet whether any code mutates it (which would kill reusing
# but not sure yet whether any code mutates it (which would kill reusing
# it across different contexts)
# it across different contexts)
scope
=
CythonScope
(
context
)
return
CythonScope
(
context
)
if
create_testscope
:
scope
.
test_cythonscope
()
return
scope
# Load test utilities for the cython scope
# Load test utilities for the cython scope
...
@@ -137,4 +150,4 @@ cython_test_extclass_utility_code = \
...
@@ -137,4 +150,4 @@ cython_test_extclass_utility_code = \
requires
=
[
undecorated_methods_protos
,
requires
=
[
undecorated_methods_protos
,
test_cython_utility_dep
])
test_cython_utility_dep
])
cythonview_testscope_utility_code
=
load_testscope_utility
(
"View.TestScope"
)
cythonview_testscope_utility_code
=
load_testscope_utility
(
"View.TestScope"
)
\ No newline at end of file
Cython/Compiler/Main.py
View file @
e023f0e3
...
@@ -65,9 +65,7 @@ class Context(object):
...
@@ -65,9 +65,7 @@ class Context(object):
import
Builtin
,
CythonScope
import
Builtin
,
CythonScope
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
if
self
.
cython_scope
is
None
:
self
.
cython_scope
=
CythonScope
.
create_cython_scope
(
self
)
Context
.
cython_scope
=
CythonScope
.
create_cython_scope
(
self
,
create_testscope
=
create_testscope
)
self
.
modules
[
"cython"
]
=
self
.
cython_scope
self
.
modules
[
"cython"
]
=
self
.
cython_scope
self
.
include_directories
=
include_directories
self
.
include_directories
=
include_directories
self
.
future_directives
=
set
()
self
.
future_directives
=
set
()
...
...
Cython/Compiler/MemoryView.py
View file @
e023f0e3
...
@@ -686,6 +686,7 @@ def get_axes_specs(env, axes):
...
@@ -686,6 +686,7 @@ def get_axes_specs(env, axes):
'''
'''
cythonscope
=
env
.
global_scope
().
context
.
cython_scope
cythonscope
=
env
.
global_scope
().
context
.
cython_scope
cythonscope
.
load_cythonscope
()
viewscope
=
cythonscope
.
viewscope
viewscope
=
cythonscope
.
viewscope
access_specs
=
tuple
([
viewscope
.
lookup
(
name
)
access_specs
=
tuple
([
viewscope
.
lookup
(
name
)
...
...
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