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
Kirill Smelkov
cython
Commits
f534aeb7
Commit
f534aeb7
authored
Jul 31, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid overly redundant recoding in memory view dtype code (format_from_typeinfo())
parent
1a0ff5e2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
Cython/Utility/MemoryView.pyx
Cython/Utility/MemoryView.pyx
+11
-15
No files found.
Cython/Utility/MemoryView.pyx
View file @
f534aeb7
...
...
@@ -1418,38 +1418,34 @@ cdef extern from *:
@
cname
(
'__pyx_format_from_typeinfo'
)
cdef
format_from_typeinfo
(
__Pyx_TypeInfo
*
type
):
"""
We want to return bytes, but python 3 doesn't allow you to do anything
useful with bytes. So use str and convert back and forth to/from unicode.
Thank you python 3 for making bytes the most useless thing ever!
"""
cdef
bytes
format_from_typeinfo
(
__Pyx_TypeInfo
*
type
):
cdef
__Pyx_StructField
*
field
cdef
__pyx_typeinfo_string
fmt
cdef
bytes
part
,
result
if
type
.
typegroup
==
'S'
:
assert
type
.
fields
!=
NULL
and
type
.
fields
.
type
!=
NULL
if
type
.
flags
&
__PYX_BUF_FLAGS_PACKED_STRUCT
:
alignment
=
'^'
alignment
=
b
'^'
else
:
alignment
=
''
alignment
=
b
''
parts
=
[
"T{"
]
parts
=
[
b
"T{"
]
field
=
type
.
fields
while
field
.
type
:
part
=
format_from_typeinfo
(
field
.
type
)
.
decode
(
'ascii'
)
parts
.
append
(
'%s:%s:'
%
(
part
,
(
<
char
*>
field
.
name
).
decode
(
'ascii'
))
)
part
=
format_from_typeinfo
(
field
.
type
)
parts
.
append
(
part
+
b':'
+
field
.
name
+
b':'
)
field
+=
1
result
=
alignment
.
join
(
parts
)
+
'}'
result
=
alignment
.
join
(
parts
)
+
b
'}'
else
:
fmt
=
__Pyx_TypeInfoToFormat
(
type
)
if
type
.
arraysize
[
0
]:
extents
=
[
str
(
type
.
arraysize
[
i
])
for
i
in
range
(
type
.
ndim
)]
result
=
"(%s)%s"
%
(
','
.
join
(
extents
),
fmt
.
string
.
decode
(
'ascii'
))
result
=
(
"(%s)"
%
','
.
join
(
extents
)).
encode
(
'ascii'
)
+
fmt
.
string
else
:
result
=
fmt
.
string
.
decode
(
'ascii'
)
result
=
fmt
.
string
return
result
.
encode
(
'ascii'
)
return
result
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