mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 23:58:52 +00:00
Fix Python host-endianness dependencies (#7773)
* In Python tests, use host-endian-independent dtypes * Fix host endianness dependence in Python flexbuffers Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
@@ -74,15 +74,15 @@ def int_sizes(value):
|
||||
|
||||
|
||||
def int_bytes(value, byte_width):
|
||||
return struct.pack({1: 'b', 2: 'h', 4: 'i', 8: 'q'}[byte_width], value)
|
||||
return struct.pack('<%s' % {1: 'b', 2: 'h', 4: 'i', 8: 'q'}[byte_width], value)
|
||||
|
||||
|
||||
def uint_bytes(value, byte_width):
|
||||
return struct.pack({1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[byte_width], value)
|
||||
return struct.pack('<%s' % {1: 'B', 2: 'H', 4: 'I', 8: 'Q'}[byte_width], value)
|
||||
|
||||
|
||||
def float_bytes(value, byte_width):
|
||||
return struct.pack({4: 'f', 8: 'd'}[byte_width], value)
|
||||
return struct.pack('<%s' % {4: 'f', 8: 'd'}[byte_width], value)
|
||||
|
||||
|
||||
def min_value(type_, byte_width):
|
||||
|
||||
Reference in New Issue
Block a user