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
Boxiang Sun
cython
Commits
d8898626
Commit
d8898626
authored
Mar 02, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce overhead for cython.array() initialiser a bit
parent
cba4212f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
Cython/Utility/MemoryView.pyx
Cython/Utility/MemoryView.pyx
+6
-10
No files found.
Cython/Utility/MemoryView.pyx
View file @
d8898626
...
...
@@ -111,7 +111,7 @@ cdef class array:
cdef
bint
dtype_is_object
def
__cinit__
(
array
self
,
tuple
shape
,
Py_ssize_t
itemsize
,
format
not
None
,
mode
=
u
"c"
,
bint
allocate_buffer
=
True
):
mode
=
"c"
,
bint
allocate_buffer
=
True
):
cdef
int
idx
cdef
Py_ssize_t
i
...
...
@@ -126,10 +126,9 @@ cdef class array:
if
self
.
itemsize
<=
0
:
raise
ValueError
(
"itemsize <= 0 for cython.array"
)
encode
=
getattr
(
format
,
'encode'
,
None
)
if
encode
:
format
=
encode
(
'ASCII'
)
self
.
_format
=
format
if
isinstance
(
format
,
unicode
):
format
=
(
<
unicode
>
format
).
encode
(
'ASCII'
)
self
.
_format
=
format
# keep a reference to the byte string
self
.
format
=
self
.
_format
# use single malloc() for both shape and strides
...
...
@@ -154,17 +153,14 @@ cdef class array:
cdef
char
order
if
mode
==
'fortran'
:
order
=
'F'
self
.
mode
=
u'fortran'
else
:
order
=
'C'
self
.
mode
=
u'c'
self
.
len
=
fill_contig_strides_array
(
self
.
_shape
,
self
.
_strides
,
itemsize
,
self
.
ndim
,
order
)
decode
=
getattr
(
mode
,
'decode'
,
None
)
if
decode
:
mode
=
decode
(
'ASCII'
)
self
.
mode
=
mode
self
.
free_data
=
allocate_buffer
self
.
dtype_is_object
=
format
==
b'O'
if
allocate_buffer
:
...
...
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