Unexpected number of bytes (chunk size) in encoding? #7
Answered
by
charlie-dufort
thorwhalen
asked this question in
Q&A
-
|
Noticed this unexpected behavior: import recode
dh_codec = recode.mk_codec('dh')
assert len(dh_codec.encode([[1.0, 1]])) == 10
hd_codec = recode.mk_codec('hd')
assert len(hd_codec.encode([[1, 1.0]])) == 16Which can be traced down to the builtin import struct
assert struct.calcsize('h') == 2
assert struct.calcsize('d') == 8
assert struct.calcsize('dh') == 10 == 2 + 8 # expected!
assert struct.calcsize('hd') == 16 # didn't expect this!What's happening here? How can I get what I expect? (10 in both cases.) |
Beta Was this translation helpful? Give feedback.
Answered by
charlie-dufort
Aug 23, 2023
Replies: 1 comment
-
|
@sylvainbonnot explained it had to do with this optional prefix character ( |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
thorwhalen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sylvainbonnot explained it had to do with this optional prefix character (
'@','=','<','>','!') which controls the byte order, size and alignment.If the first character is not one of these,
'@'is assumed.Using
'='removes the "unexpected behavior":