(self, obj)
| 820 | dispatch[bool] = save_bool |
| 821 | |
| 822 | def save_long(self, obj): |
| 823 | if self.bin: |
| 824 | # If the int is small enough to fit in a signed 4-byte 2's-comp |
| 825 | # format, we can store it more efficiently than the general |
| 826 | # case. |
| 827 | # First one- and two-byte unsigned ints: |
| 828 | if obj >= 0: |
| 829 | if obj <= 0xff: |
| 830 | self.write(BININT1 + pack("<B", obj)) |
| 831 | return |
| 832 | if obj <= 0xffff: |
| 833 | self.write(BININT2 + pack("<H", obj)) |
| 834 | return |
| 835 | # Next check for 4-byte signed ints: |
| 836 | if -0x80000000 <= obj <= 0x7fffffff: |
| 837 | self.write(BININT + pack("<i", obj)) |
| 838 | return |
| 839 | if self.proto >= 2: |
| 840 | encoded = encode_long(obj) |
| 841 | n = len(encoded) |
| 842 | if n < 256: |
| 843 | self.write(LONG1 + pack("<B", n) + encoded) |
| 844 | else: |
| 845 | self.write(LONG4 + pack("<i", n) + encoded) |
| 846 | return |
| 847 | if -0x80000000 <= obj <= 0x7fffffff: |
| 848 | self.write(INT + repr(obj).encode("ascii") + b'\n') |
| 849 | else: |
| 850 | self.write(LONG + repr(obj).encode("ascii") + b'L\n') |
| 851 | dispatch[int] = save_long |
| 852 | |
| 853 | def save_float(self, obj): |
nothing calls this directly
no test coverage detected