[issue42165] Question about converting numpy float to bytes (bug??)
New submission from hyoxt121 : Hi! In order to convert numpy float to bytes, we are using tobytes() method: import pickle import numpy as np pickle.loads(np.float64(0.34103)) and the expected result is like below (because np.float64(0.34103) is not bytes objects, appropriate errors are expected) --- UnpicklingError Traceback (most recent call last) in > 1 pickle.loads(np.float64(0.34103)) UnpicklingError: invalid load key, '\xc1'. Here we have some questions that some numbers (it is rare) like 0.34104 prints the following result without errors. pickle.loads(np.float64(0.34104)) => True This occurs only when the converted bytes start with b'\x88 (for example 0.04263, 0.08526, 0.11651 ...) Can anyone answer whether this issue is Python bugs? Any answer will be highly appreciated. -- components: Library (Lib) messages: 379738 nosy: hyoxt121 priority: normal severity: normal status: open title: Question about converting numpy float to bytes (bug??) type: behavior versions: Python 3.6 ___ Python tracker <https://bugs.python.org/issue42165> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42165] Question about converting numpy float to bytes (bug??)
hyoxt121 added the comment: If so, regardless of invalid operation, can anyone explain why "pickle.loads(np.float64(0.34104))" prints "True"? -- ___ Python tracker <https://bugs.python.org/issue42165> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42168] Question about deserializing some numbers (bug??)
New submission from hyoxt121 : Hi! In order to deserialize bytes object, we use pickle.loads(): import pickle import numpy as np pickle.loads(np.float64(0.34103)) and the expected result is like below (because np.float64(0.34103) is not bytes objects, appropriate errors are expected) --- UnpicklingError Traceback (most recent call last) in > 1 pickle.loads(np.float64(0.34103)) UnpicklingError: invalid load key, '\xc1'. Here we have some questions that some numbers (it is rare) like 0.34104 prints the following result without errors. pickle.loads(np.float64(0.34104)) => True This occurs only when the converted bytes start with b'\x88 (for example 0.04263, 0.08526, 0.11651 ...) np.float64(0.34104).tobytes() => b'\x88.\xa8o\x99\xd3\xd5?' Can anyone answer whether this issue is Python bugs? Any answer will be highly appreciated. -- components: Library (Lib) messages: 379750 nosy: hyoxt121 priority: normal severity: normal status: open title: Question about deserializing some numbers (bug??) versions: Python 3.6 ___ Python tracker <https://bugs.python.org/issue42168> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42165] closed (reopen with other issue)
Change by hyoxt121 : -- title: Question about converting numpy float to bytes (bug??) -> closed (reopen with other issue) ___ Python tracker <https://bugs.python.org/issue42165> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42165] Question about converting numpy float to bytes (bug??)
hyoxt121 added the comment: I will close and reopen again with some modification. -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue42165> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42168] Question about deserializing some numbers (bug??)
hyoxt121 added the comment: Can anyone explain "pickle.loads(np.float64(0.34104))" prints "True"? -- ___ Python tracker <https://bugs.python.org/issue42168> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com