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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
b3d97a43
Commit
b3d97a43
authored
Aug 26, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable a test
parent
63f17c88
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
25 deletions
+39
-25
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-5
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+5
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
docs/src/userguide/language_basics.rst
docs/src/userguide/language_basics.rst
+7
-3
docs/src/userguide/memoryviews.rst
docs/src/userguide/memoryviews.rst
+2
-1
tests/run/memoryview.pyx
tests/run/memoryview.pyx
+1
-1
tests/run/memslice.pyx
tests/run/memslice.pyx
+19
-7
tests/run/struct_conversion.pyx
tests/run/struct_conversion.pyx
+3
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
b3d97a43
...
@@ -1644,10 +1644,6 @@ class NameNode(AtomicExprNode):
...
@@ -1644,10 +1644,6 @@ class NameNode(AtomicExprNode):
(
self
.
cf_maybe_null
or
self
.
cf_is_null
)
and
not
self
.
allow_null
)
(
self
.
cf_maybe_null
or
self
.
cf_is_null
)
and
not
self
.
allow_null
)
null_code
=
entry
.
type
.
check_for_null_code
(
entry
.
cname
)
null_code
=
entry
.
type
.
check_for_null_code
(
entry
.
cname
)
# if entry.type.is_memoryviewslice:
# have_gil = not self.in_nogil_context
# code.put_incref_memoryviewslice(entry.cname, have_gil)
memslice_check
=
entry
.
type
.
is_memoryviewslice
and
self
.
initialized_check
memslice_check
=
entry
.
type
.
is_memoryviewslice
and
self
.
initialized_check
if
null_code
and
raise_unbound
and
(
entry
.
type
.
is_pyobject
or
memslice_check
):
if
null_code
and
raise_unbound
and
(
entry
.
type
.
is_pyobject
or
memslice_check
):
...
@@ -1764,7 +1760,7 @@ class NameNode(AtomicExprNode):
...
@@ -1764,7 +1760,7 @@ class NameNode(AtomicExprNode):
rhs
=
rhs
,
rhs
=
rhs
,
code
=
code
,
code
=
code
,
incref_rhs
=
rhs
.
is_name
,
incref_rhs
=
rhs
.
is_name
,
have_gil
=
not
self
.
nogil
)
have_gil
=
not
self
.
in_nogil_context
)
def
generate_acquire_buffer
(
self
,
rhs
,
code
):
def
generate_acquire_buffer
(
self
,
rhs
,
code
):
# rhstmp is only used in case the rhs is a complicated expression leading to
# rhstmp is only used in case the rhs is a complicated expression leading to
...
...
Cython/Compiler/MemoryView.py
View file @
b3d97a43
...
@@ -92,16 +92,17 @@ def put_acquire_memoryviewslice(lhs_cname, lhs_type, lhs_pos, rhs, code,
...
@@ -92,16 +92,17 @@ def put_acquire_memoryviewslice(lhs_cname, lhs_type, lhs_pos, rhs, code,
# Allow uninitialized assignment
# Allow uninitialized assignment
#code.putln(code.put_error_if_unbound(lhs_pos, rhs.entry))
#code.putln(code.put_error_if_unbound(lhs_pos, rhs.entry))
put_assign_to_memviewslice
(
lhs_cname
,
rhstmp
,
lhs_type
,
code
,
incref_rhs
)
put_assign_to_memviewslice
(
lhs_cname
,
rhstmp
,
lhs_type
,
code
,
incref_rhs
,
have_gil
=
have_gil
)
if
not
pretty_rhs
:
if
not
pretty_rhs
:
code
.
funcstate
.
release_temp
(
rhstmp
)
code
.
funcstate
.
release_temp
(
rhstmp
)
def
put_assign_to_memviewslice
(
lhs_cname
,
rhs_cname
,
memviewslicetype
,
code
,
def
put_assign_to_memviewslice
(
lhs_cname
,
rhs_cname
,
memviewslicetype
,
code
,
incref_rhs
=
False
):
incref_rhs
=
False
,
have_gil
=
False
):
code
.
put_xdecref_memoryviewslice
(
lhs_cname
)
code
.
put_xdecref_memoryviewslice
(
lhs_cname
,
have_gil
=
have_gil
)
if
incref_rhs
:
if
incref_rhs
:
code
.
put_incref_memoryviewslice
(
rhs_cname
)
code
.
put_incref_memoryviewslice
(
rhs_cname
,
have_gil
=
have_gil
)
code
.
putln
(
"%s = %s;"
%
(
lhs_cname
,
rhs_cname
))
code
.
putln
(
"%s = %s;"
%
(
lhs_cname
,
rhs_cname
))
...
...
Cython/Compiler/Nodes.py
View file @
b3d97a43
...
@@ -4360,7 +4360,7 @@ class ReturnStatNode(StatNode):
...
@@ -4360,7 +4360,7 @@ class ReturnStatNode(StatNode):
lhs_pos
=
self
.
value
.
pos
,
lhs_pos
=
self
.
value
.
pos
,
rhs
=
self
.
value
,
rhs
=
self
.
value
,
code
=
code
,
code
=
code
,
incref_rhs
=
Tru
e
,
incref_rhs
=
value
.
is_nam
e
,
have_gil
=
self
.
in_nogil_context
)
have_gil
=
self
.
in_nogil_context
)
else
:
else
:
self
.
value
.
make_owned_reference
(
code
)
self
.
value
.
make_owned_reference
(
code
)
...
...
docs/src/userguide/language_basics.rst
View file @
b3d97a43
...
@@ -106,14 +106,18 @@ using normal C declaration syntax. For example,::
...
@@ -106,14 +106,18 @@ using normal C declaration syntax. For example,::
When a parameter of a Python function is declared to have a C data type, it is
When a parameter of a Python function is declared to have a C data type, it is
passed in as a Python object and automatically converted to a C value, if
passed in as a Python object and automatically converted to a C value, if
possible. Automatic conversion is currently only possible for numeric types
possible. Automatic conversion is currently only possible for numeric types,
and string types; attempting to use any other type for the parameter of a
string types and structs (composed recusively of any of these types);
attempting to use any other type for the parameter of a
Python function will result in a compile-time error.
Python function will result in a compile-time error.
Care must be taken with strings to ensure a reference if the pointer is to be used
after the call. Structs can be obtained from Python mappings, and again care must be taken
with string attributes if they are to be used after the function returns.
C functions, on the other hand, can have parameters of any type, since they're
C functions, on the other hand, can have parameters of any type, since they're
passed in directly using a normal C function call.
passed in directly using a normal C function call.
A more complete comparison of the pros and cons of these different method
A more complete comparison of the pros and cons of these different method
types can be found at :ref:`early-binding-for-speed`.
types can be found at :ref:`early-binding-for-speed`.
Python objects as parameters and return values
Python objects as parameters and return values
...
...
docs/src/userguide/memoryviews.rst
View file @
b3d97a43
...
@@ -89,7 +89,7 @@ cdef indirect_contiguous = Enum("<contiguous and indirect>")
...
@@ -89,7 +89,7 @@ cdef indirect_contiguous = Enum("<contiguous and indirect>")
* generic - strided and direct or indirect
* generic - strided and direct or indirect
* strided - strided and direct (this is the default)
* strided - strided and direct (this is the default)
* indirect - strided and indirect
(must not be the last dimension)
* indirect - strided and indirect
* contiguous - contiguous and direct
* contiguous - contiguous and direct
* indirect_contiguous - the list of pointers is contiguous
* indirect_contiguous - the list of pointers is contiguous
...
@@ -199,3 +199,4 @@ In the future some functionality may be added for convenience, like
...
@@ -199,3 +199,4 @@ In the future some functionality may be added for convenience, like
1. A numpy-like `.flat` attribute (that allows efficient iteration)
1. A numpy-like `.flat` attribute (that allows efficient iteration)
2. A numpy-like `.reshape` method
2. A numpy-like `.reshape` method
3. A method `to_numpy` which would convert a memoryview object to a NumPy object
3. A method `to_numpy` which would convert a memoryview object to a NumPy object
4. Indexing with newaxis or None to introduce a new axis
tests/run/memoryview.pyx
View file @
b3d97a43
...
@@ -590,7 +590,7 @@ def assign_temporary_to_object(object[:] mslice):
...
@@ -590,7 +590,7 @@ def assign_temporary_to_object(object[:] mslice):
def
print_offsets
(
*
args
,
size
=
0
,
newline
=
True
):
def
print_offsets
(
*
args
,
size
=
0
,
newline
=
True
):
for
item
in
args
:
for
item
in
args
:
print
item
/
size
,
print
item
/
/
size
,
if
newline
:
print
if
newline
:
print
...
...
tests/run/memslice.pyx
View file @
b3d97a43
...
@@ -1087,12 +1087,19 @@ def buffer_nogil():
...
@@ -1087,12 +1087,19 @@ def buffer_nogil():
#
#
### Test cdef functions
### Test cdef functions
#
#
class
UniqueObject
(
object
):
def
__init__
(
self
,
value
):
self
.
value
=
value
objs
=
[[
"spam"
],
[
"ham"
],
[
"eggs"
]]
def
__repr__
(
self
):
return
self
.
value
objs
=
[[
UniqueObject
(
"spam"
)],
[
UniqueObject
(
"ham"
)],
[
UniqueObject
(
"eggs"
)]]
addref
(
*
objs
)
cdef
cdef
_function
(
int
[:]
buf1
,
object
[::
view
.
indirect
,
:]
buf2
=
ObjectMockBuffer
(
None
,
objs
)):
cdef
cdef
_function
(
int
[:]
buf1
,
object
[::
view
.
indirect
,
:]
buf2
=
ObjectMockBuffer
(
None
,
objs
)):
print
'cdef called'
print
'cdef called'
print
buf1
[
6
],
buf2
[
1
,
0
]
print
buf1
[
6
],
buf2
[
1
,
0
]
buf2
[
1
,
0
]
=
"eggs"
buf2
[
1
,
0
]
=
UniqueObject
(
"eggs"
)
@
testcase
@
testcase
def
test_cdef_function
(
o1
,
o2
=
None
):
def
test_cdef_function
(
o1
,
o2
=
None
):
...
@@ -1107,9 +1114,12 @@ def test_cdef_function(o1, o2=None):
...
@@ -1107,9 +1114,12 @@ def test_cdef_function(o1, o2=None):
cdef called
cdef called
6 eggs
6 eggs
released A
released A
>>> L = [[x] for x in range(25)]
>>> B = ObjectMockBuffer("B", L, shape=(5, 5))
>> L = [[x] for x in range(25)]
>>> test_cdef_function(A, B)
>> addref(*L)
>> B = ObjectMockBuffer("B", L, shape=(5, 5))
>> test_cdef_function(A, B)
acquired A
acquired A
cdef called
cdef called
6 eggs
6 eggs
...
@@ -1132,12 +1142,14 @@ def test_cdef_function(o1, o2=None):
...
@@ -1132,12 +1142,14 @@ def test_cdef_function(o1, o2=None):
cdef
_function
(
o1
,
o2
)
cdef
_function
(
o1
,
o2
)
cdef
int
[:]
global_A
=
IntMockBuffer
(
"Global_A"
,
range
(
10
))
cdef
int
[:]
global_A
=
IntMockBuffer
(
"Global_A"
,
range
(
10
))
addref
(
*
objs
)
cdef
object
[::
view
.
indirect
,
:]
global_B
=
ObjectMockBuffer
(
None
,
objs
)
cdef
object
[::
view
.
indirect
,
:]
global_B
=
ObjectMockBuffer
(
None
,
objs
)
cdef
cdef
_function2
(
int
[:]
buf1
,
object
[::
view
.
indirect
,
:]
buf2
=
global_B
):
cdef
cdef
_function2
(
int
[:]
buf1
,
object
[::
view
.
indirect
,
:]
buf2
=
global_B
):
print
'cdef2 called'
print
'cdef2 called'
print
buf1
[
6
],
buf2
[
1
,
0
]
print
buf1
[
6
],
buf2
[
1
,
0
]
buf2
[
1
,
0
]
=
"eggs"
buf2
[
1
,
0
]
=
UniqueObject
(
"eggs"
)
@
testcase
@
testcase
def
test_cdef_function2
():
def
test_cdef_function2
():
...
@@ -1164,7 +1176,7 @@ def test_cdef_function2():
...
@@ -1164,7 +1176,7 @@ def test_cdef_function2():
def
print_offsets
(
*
args
,
size
=
0
,
newline
=
True
):
def
print_offsets
(
*
args
,
size
=
0
,
newline
=
True
):
for
item
in
args
:
for
item
in
args
:
print
item
/
size
,
print
item
/
/
size
,
if
newline
:
print
if
newline
:
print
...
...
tests/run/struct_conversion.pyx
View file @
b3d97a43
...
@@ -69,17 +69,17 @@ cdef struct MyStruct:
...
@@ -69,17 +69,17 @@ cdef struct MyStruct:
def
test_obj_to_struct
(
MyStruct
mystruct
):
def
test_obj_to_struct
(
MyStruct
mystruct
):
"""
"""
>>> test_obj_to_struct(dict(c=10, i=20, f=6.7, s="hello"))
>>> test_obj_to_struct(dict(c=10, i=20, f=6.7, s=
b
"hello"))
c=10 i=20 f=6.70 s=hello
c=10 i=20 f=6.70 s=hello
>>> test_obj_to_struct(None)
>>> test_obj_to_struct(None)
Traceback (most recent call last):
Traceback (most recent call last):
...
...
TypeError: Expected a mapping, not NoneType
TypeError: Expected a mapping, not NoneType
>>> test_obj_to_struct(dict(s="world"))
>>> test_obj_to_struct(dict(s=
b
"world"))
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: No value specified for struct attribute 'c'
ValueError: No value specified for struct attribute 'c'
>>> test_obj_to_struct(dict(c="world"))
>>> test_obj_to_struct(dict(c=
b
"world"))
Traceback (most recent call last):
Traceback (most recent call last):
...
...
TypeError: an integer is required
TypeError: an integer is required
...
...
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