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
class
CythonScope
(
ModuleScope
):
is_cython_builtin
=
1
_cythonscope_initialized
=
False
def
__init__
(
self
,
context
):
ModuleScope
.
__init__
(
self
,
u'cython'
,
None
,
None
)
...
...
@@ -23,11 +24,26 @@ class CythonScope(ModuleScope):
if
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
):
error
(
"cython.%s is not available"
%
module_name
,
pos
)
def
find_submodule
(
self
,
module_name
):
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
:
return
entry
.
as_module
else
:
...
...
@@ -68,13 +84,15 @@ class CythonScope(ModuleScope):
defining
=
1
,
cname
=
'PyObject_TypeCheck'
)
# self.test_cythonscope()
def
test_cythonscope
(
self
):
def
load_cythonscope
(
self
):
"""
Creates some entries for testing purposes and entries for
cython.array() and for cython.view.*.
"""
if
self
.
_cythonscope_initialized
:
return
self
.
_cythonscope_initialized
=
True
cython_testscope_utility_code
.
declare_in_scope
(
self
,
cython_scope
=
self
)
cython_test_extclass_utility_code
.
declare_in_scope
(
...
...
@@ -100,16 +118,11 @@ class CythonScope(ModuleScope):
# 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,
# but not sure yet whether any code mutates it (which would kill reusing
# it across different contexts)
scope
=
CythonScope
(
context
)
if
create_testscope
:
scope
.
test_cythonscope
()
return
scope
return
CythonScope
(
context
)
# Load test utilities for the cython scope
...
...
@@ -137,4 +150,4 @@ cython_test_extclass_utility_code = \
requires
=
[
undecorated_methods_protos
,
test_cython_utility_dep
])
cythonview_testscope_utility_code
=
load_testscope_utility
(
"View.TestScope"
)
\ No newline at end of file
cythonview_testscope_utility_code
=
load_testscope_utility
(
"View.TestScope"
)
Cython/Compiler/Main.py
View file @
e023f0e3
...
...
@@ -65,9 +65,7 @@ class Context(object):
import
Builtin
,
CythonScope
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
if
self
.
cython_scope
is
None
:
Context
.
cython_scope
=
CythonScope
.
create_cython_scope
(
self
,
create_testscope
=
create_testscope
)
self
.
cython_scope
=
CythonScope
.
create_cython_scope
(
self
)
self
.
modules
[
"cython"
]
=
self
.
cython_scope
self
.
include_directories
=
include_directories
self
.
future_directives
=
set
()
...
...
Cython/Compiler/MemoryView.py
View file @
e023f0e3
...
...
@@ -686,6 +686,7 @@ def get_axes_specs(env, axes):
'''
cythonscope
=
env
.
global_scope
().
context
.
cython_scope
cythonscope
.
load_cythonscope
()
viewscope
=
cythonscope
.
viewscope
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