Dump the given float to JSON Parameters ---------- value: float Value to dump Returns ------- Union[float, str] Dumped value, either a float or the strings
(value: float)
| 531 | |
| 532 | |
| 533 | def _dump_float(value: float) -> Union[float, str]: |
| 534 | """Dump the given float to JSON |
| 535 | |
| 536 | Parameters |
| 537 | ---------- |
| 538 | value: float |
| 539 | Value to dump |
| 540 | |
| 541 | Returns |
| 542 | ------- |
| 543 | Union[float, str] |
| 544 | Dumped value, either a float or the strings |
| 545 | """ |
| 546 | if value == float("inf"): |
| 547 | return INFINITY |
| 548 | if value == -float("inf"): |
| 549 | return NEG_INFINITY |
| 550 | if isinstance(value, float) and math.isnan(value): |
| 551 | return NAN |
| 552 | return value |
| 553 | |
| 554 | |
| 555 | def load_varint(stream: "SupportsRead[bytes]") -> Tuple[int, bytes]: |