This is an automated email from the ASF dual-hosted git repository.

jmalkin pushed a commit to branch serde_format_fix
in repository https://gitbox.apache.org/repos/asf/datasketches-python.git

commit 8d8998edfbb4a5e25348c5338d7b1a15eb191dc3
Author: Jon Malkin <[email protected]>
AuthorDate: Thu Nov 16 16:56:03 2023 -0800

    Update PySerDe.py
    
    Properly read/write longs as 8-bit values, based on the format table for 
the struct class: 
https://docs.python.org/3/library/struct.html#format-characters
---
 datasketches/PySerDe.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/datasketches/PySerDe.py b/datasketches/PySerDe.py
index e4de82d..9a24484 100644
--- a/datasketches/PySerDe.py
+++ b/datasketches/PySerDe.py
@@ -75,10 +75,10 @@ class PyLongsSerDe(PyObjectSerDe):
     return int(8)
 
   def to_bytes(self, item):
-    return struct.pack('<l', item)
+    return struct.pack('<q', item)
 
   def from_bytes(self, data: bytes, offset: int):
-    val = struct.unpack_from('<l', data, offset)[0]
+    val = struct.unpack_from('<q', data, offset)[0]
     return (val, 8)
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to