(self, obj)
| 749 | dispatch[bool] = save_bool |
| 750 | |
| 751 | def save_long(self, obj): |
| 752 | if self.bin: |
| 753 | # If the int is small enough to fit in a signed 4-byte 2's-comp |
| 754 | # format, we can store it more efficiently than the general |
| 755 | # case. |
| 756 | # First one- and two-byte unsigned ints: |
| 757 | if obj >= 0: |
| 758 | if obj <= 0xff: |
| 759 | self.write(BININT1 + pack("<B", obj)) |
| 760 | return |
| 761 | if obj <= 0xffff: |
| 762 | self.write(BININT2 + pack("<H", obj)) |
| 763 | return |
| 764 | # Next check for 4-byte signed ints: |
| 765 | if -0x80000000 <= obj <= 0x7fffffff: |
| 766 | self.write(BININT + pack("<i", obj)) |
| 767 | return |
| 768 | if self.proto >= 2: |
| 769 | encoded = encode_long(obj) |
| 770 | n = len(encoded) |
| 771 | if n < 256: |
| 772 | self.write(LONG1 + pack("<B", n) + encoded) |
| 773 | else: |
| 774 | self.write(LONG4 + pack("<i", n) + encoded) |
| 775 | return |
| 776 | if -0x80000000 <= obj <= 0x7fffffff: |
| 777 | self.write(INT + repr(obj).encode("ascii") + b'\n') |
| 778 | else: |
| 779 | self.write(LONG + repr(obj).encode("ascii") + b'L\n') |
| 780 | dispatch[int] = save_long |
| 781 | |
| 782 | def save_float(self, obj): |
nothing calls this directly
no test coverage detected