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
f327c492
Commit
f327c492
authored
Oct 26, 2016
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use cython.view.array utility code on cimport.
Fixes #1502
parent
c6dfb487
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+1
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+12
-10
No files found.
Cython/Compiler/Code.py
View file @
f327c492
...
...
@@ -1478,7 +1478,7 @@ class GlobalState(object):
See UtilityCode.
"""
if
utility_code
not
in
self
.
utility_codes
:
if
utility_code
and
utility_code
not
in
self
.
utility_codes
:
self
.
utility_codes
.
add
(
utility_code
)
utility_code
.
put_code
(
self
)
...
...
Cython/Compiler/Nodes.py
View file @
f327c492
...
...
@@ -7312,14 +7312,19 @@ class EnsureGILNode(GILExitNode):
code
.
put_ensure_gil
(
declare_gilstate
=
False
)
def
cython_view_utility_code
():
from
.
import
MemoryView
return
MemoryView
.
view_utility_code
utility_code_for_cimports
=
{
# utility code (or inlining c) in a pxd (or pyx) file.
# TODO: Consider a generic user-level mechanism for importing
'cpython.array'
:
(
"ArrayAPI"
,
"arrayarray.h"
),
'cpython.array.array'
:
(
"ArrayAPI"
,
"arrayarray.h"
),
'cpython.array'
:
lambda
:
UtilityCode
.
load_cached
(
"ArrayAPI"
,
"arrayarray.h"
),
'cpython.array.array'
:
lambda
:
UtilityCode
.
load_cached
(
"ArrayAPI"
,
"arrayarray.h"
),
'cython.view'
:
cython_view_utility_code
,
}
utility_code_for_imports
=
{
# utility code used when special modules are imported.
# TODO: Consider a generic user-level mechanism for importing
...
...
@@ -7362,8 +7367,7 @@ class CImportStatNode(StatNode):
name
=
self
.
as_name
or
self
.
module_name
env
.
declare_module
(
name
,
module_scope
,
self
.
pos
)
if
self
.
module_name
in
utility_code_for_cimports
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
*
utility_code_for_cimports
[
self
.
module_name
]))
env
.
use_utility_code
(
utility_code_for_cimports
[
self
.
module_name
]())
def
analyse_expressions
(
self
,
env
):
return
self
...
...
@@ -7422,15 +7426,13 @@ class FromCImportStatNode(StatNode):
local_name
=
as_name
or
name
env
.
add_imported_entry
(
local_name
,
entry
,
pos
)
if
module_name
.
startswith
(
'cpython'
):
# enough for now
if
module_name
.
startswith
(
'cpython'
)
or
module_name
.
startswith
(
'cython'
)
:
# enough for now
if
module_name
in
utility_code_for_cimports
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
*
utility_code_for_cimports
[
module_name
]))
env
.
use_utility_code
(
utility_code_for_cimports
[
module_name
]())
for
_
,
name
,
_
,
_
in
self
.
imported_names
:
fqname
=
'%s.%s'
%
(
module_name
,
name
)
if
fqname
in
utility_code_for_cimports
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
*
utility_code_for_cimports
[
fqname
]))
env
.
use_utility_code
(
utility_code_for_cimports
[
fqname
]())
def
declaration_matches
(
self
,
entry
,
kind
):
if
not
entry
.
is_type
:
...
...
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