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
c041335f
Commit
c041335f
authored
Aug 12, 2009
by
Kurt Smith
Committed by
Mark Florisson
Sep 30, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nonecheck directive works for memoryviewslices.
parent
bd77c8db
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-2
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+8
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+9
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
c041335f
...
@@ -3929,7 +3929,7 @@ class AttributeNode(ExprNode):
...
@@ -3929,7 +3929,7 @@ class AttributeNode(ExprNode):
self
.
obj
.
result_as
(
self
.
obj
.
type
),
self
.
obj
.
result_as
(
self
.
obj
.
type
),
rhs
.
result_as
(
self
.
ctype
())))
rhs
.
result_as
(
self
.
ctype
())))
else
:
else
:
if
(
self
.
obj
.
type
.
is_extension_type
if
(
self
.
obj
.
type
.
needs_nonecheck
()
and
self
.
needs_none_check
and
self
.
needs_none_check
and
code
.
globalstate
.
directives
[
'nonecheck'
]):
and
code
.
globalstate
.
directives
[
'nonecheck'
]):
self
.
put_nonecheck
(
code
)
self
.
put_nonecheck
(
code
)
...
@@ -3978,7 +3978,13 @@ class AttributeNode(ExprNode):
...
@@ -3978,7 +3978,13 @@ class AttributeNode(ExprNode):
def
put_nonecheck
(
self
,
code
):
def
put_nonecheck
(
self
,
code
):
code
.
globalstate
.
use_utility_code
(
raise_noneattr_error_utility_code
)
code
.
globalstate
.
use_utility_code
(
raise_noneattr_error_utility_code
)
code
.
putln
(
"if (%s) {"
%
code
.
unlikely
(
"%s == Py_None"
)
%
self
.
obj
.
result_as
(
PyrexTypes
.
py_object_type
))
if
self
.
obj
.
type
.
is_extension_type
:
test
=
"%s == Py_None"
%
self
.
obj
.
result_as
(
PyrexTypes
.
py_object_type
)
elif
self
.
obj
.
type
.
is_memoryviewslice
:
test
=
"!%s.memview"
%
self
.
obj
.
result
()
else
:
assert
False
code
.
putln
(
"if (%s) {"
%
code
.
unlikely
(
test
))
code
.
putln
(
"__Pyx_RaiseNoneAttributeError(
\
"
%s
\
"
);"
%
self
.
attribute
)
code
.
putln
(
"__Pyx_RaiseNoneAttributeError(
\
"
%s
\
"
);"
%
self
.
attribute
)
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
...
...
Cython/Compiler/MemoryView.py
View file @
c041335f
...
@@ -218,6 +218,14 @@ static int %s(const __Pyx_memviewslice mvs) {
...
@@ -218,6 +218,14 @@ static int %s(const __Pyx_memviewslice mvs) {
return
decl
,
impl
return
decl
,
impl
copy_to_template
=
'''
static int %(copy_to_name)s(const __Pyx_memviewslice from_mvs, __Pyx_memviewslice to_mvs) {
/* ensure from_mvs & to_mvs have the same shape & dtype */
}
'''
copy_template
=
'''
copy_template
=
'''
static __Pyx_memviewslice %(copy_name)s(const __Pyx_memviewslice from_mvs) {
static __Pyx_memviewslice %(copy_name)s(const __Pyx_memviewslice from_mvs) {
...
...
Cython/Compiler/PyrexTypes.py
View file @
c041335f
...
@@ -174,6 +174,9 @@ class PyrexType(BaseType):
...
@@ -174,6 +174,9 @@ class PyrexType(BaseType):
# abstract
# abstract
pass
pass
def
needs_nonecheck
(
self
):
return
0
def
public_decl
(
base_code
,
dll_linkage
):
def
public_decl
(
base_code
,
dll_linkage
):
if
dll_linkage
:
if
dll_linkage
:
...
@@ -362,6 +365,9 @@ class MemoryViewSliceType(PyrexType):
...
@@ -362,6 +365,9 @@ class MemoryViewSliceType(PyrexType):
self
.
is_c_contig
,
self
.
is_f_contig
=
MemoryView
.
is_cf_contig
(
self
.
axes
)
self
.
is_c_contig
,
self
.
is_f_contig
=
MemoryView
.
is_cf_contig
(
self
.
axes
)
assert
not
(
self
.
is_c_contig
and
self
.
is_f_contig
)
assert
not
(
self
.
is_c_contig
and
self
.
is_f_contig
)
def
needs_nonecheck
(
self
):
return
True
def
is_complete
(
self
):
def
is_complete
(
self
):
# incomplete since the underlying struct doesn't have a cython.memoryview object.
# incomplete since the underlying struct doesn't have a cython.memoryview object.
return
0
return
0
...
@@ -671,6 +677,9 @@ class PyExtensionType(PyObjectType):
...
@@ -671,6 +677,9 @@ class PyExtensionType(PyObjectType):
is_extension_type
=
1
is_extension_type
=
1
has_attributes
=
1
has_attributes
=
1
def
needs_nonecheck
(
self
):
return
True
objtypedef_cname
=
None
objtypedef_cname
=
None
def
__init__
(
self
,
name
,
typedef_flag
,
base_type
,
is_external
=
0
):
def
__init__
(
self
,
name
,
typedef_flag
,
base_type
,
is_external
=
0
):
...
...
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