chaokunyang commented on code in PR #3329:
URL: https://github.com/apache/fory/pull/3329#discussion_r2836126639
##########
python/pyfory/serialization.pyx:
##########
@@ -1714,6 +1714,24 @@ cpdef inline read_nullable_pystr(Buffer buffer):
else:
return None
+cpdef inline write_nullable_bfloat16(Buffer buffer, value):
+ if value is None:
+ buffer.write_int8(NULL_FLAG)
+ else:
+ buffer.write_int8(NOT_NULL_VALUE_FLAG)
+ from pyfory.bfloat16 import BFloat16
+ if isinstance(value, BFloat16):
+ buffer.write_bfloat16(value.to_bits())
+ else:
+ buffer.write_bfloat16(BFloat16(value).to_bits())
+
+cpdef inline read_nullable_bfloat16(Buffer buffer):
+ if buffer.read_int8() == NOT_NULL_VALUE_FLAG:
+ from pyfory.bfloat16 import BFloat16
+ return BFloat16.from_bits(buffer.read_bfloat16())
Review Comment:
And could you rename `BFloat16` to `bfloat16`? This is a primitive type, use
lowercase name style make it looks like buildin
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]