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
036637f1
Commit
036637f1
authored
Aug 28, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove a tiny bit of time overhead in mockbuffer test support.
parent
ddc9a18c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
tests/buffers/mockbuffers.pxi
tests/buffers/mockbuffers.pxi
+9
-5
No files found.
tests/buffers/mockbuffers.pxi
View file @
036637f1
...
...
@@ -31,11 +31,12 @@ cdef class MockBuffer:
def
__init__
(
self
,
label
,
data
,
shape
=
None
,
strides
=
None
,
format
=
None
,
writable
=
True
,
offset
=
0
):
# It is important not to store references to data after the constructor
# as refcounting is checked on object buffers.
cdef
Py_ssize_t
x
,
s
,
cumprod
,
itemsize
self
.
label
=
label
self
.
release_ok
=
True
self
.
log
=
""
self
.
offset
=
offset
self
.
itemsize
=
self
.
get_itemsize
()
self
.
itemsize
=
itemsize
=
self
.
get_itemsize
()
self
.
writable
=
writable
if
format
is
None
:
format
=
self
.
get_default_format
()
if
shape
is
None
:
shape
=
(
len
(
data
),)
...
...
@@ -48,7 +49,7 @@ cdef class MockBuffer:
strides
.
append
(
cumprod
)
cumprod
*=
s
strides
.
reverse
()
strides
=
[
x
*
self
.
itemsize
for
x
in
strides
]
strides
=
[
x
*
itemsize
for
x
in
strides
]
suboffsets
=
[
-
1
]
*
len
(
shape
)
datashape
=
[
len
(
data
)]
p
=
data
...
...
@@ -61,8 +62,10 @@ cdef class MockBuffer:
self
.
ndim
=
<
int
>
len
(
datashape
)
shape
=
datashape
self
.
buffer
=
self
.
create_indirect_buffer
(
data
,
shape
)
suboffsets
=
[
0
]
*
(
self
.
ndim
-
1
)
+
[
-
1
]
strides
=
[
sizeof
(
void
*
)]
*
(
self
.
ndim
-
1
)
+
[
self
.
itemsize
]
suboffsets
=
[
0
]
*
self
.
ndim
suboffsets
[
-
1
]
=
-
1
strides
=
[
sizeof
(
void
*
)]
*
self
.
ndim
strides
[
-
1
]
=
itemsize
self
.
suboffsets
=
self
.
list_to_sizebuf
(
suboffsets
)
else
:
# strided and/or simple access
...
...
@@ -75,7 +78,7 @@ cdef class MockBuffer:
except
AttributeError
:
pass
self
.
format
=
format
self
.
len
=
len
(
data
)
*
self
.
itemsize
self
.
len
=
len
(
data
)
*
itemsize
self
.
strides
=
self
.
list_to_sizebuf
(
strides
)
self
.
shape
=
self
.
list_to_sizebuf
(
shape
)
...
...
@@ -119,6 +122,7 @@ cdef class MockBuffer:
return
buf
cdef
Py_ssize_t
*
list_to_sizebuf
(
self
,
l
):
cdef
Py_ssize_t
i
,
x
cdef
size_t
n
=
<
size_t
>
len
(
l
)
*
sizeof
(
Py_ssize_t
)
cdef
Py_ssize_t
*
buf
=
<
Py_ssize_t
*>
stdlib
.
malloc
(
n
)
for
i
,
x
in
enumerate
(
l
):
...
...
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