This function dumps a python object as a tnetstring.
(value: TSerializable)
| 48 | |
| 49 | |
| 50 | def dumps(value: TSerializable) -> bytes: |
| 51 | """ |
| 52 | This function dumps a python object as a tnetstring. |
| 53 | """ |
| 54 | # This uses a deque to collect output fragments in reverse order, |
| 55 | # then joins them together at the end. It's measurably faster |
| 56 | # than creating all the intermediate strings. |
| 57 | q: collections.deque = collections.deque() |
| 58 | _rdumpq(q, 0, value) |
| 59 | return b"".join(q) |
| 60 | |
| 61 | |
| 62 | def dump(value: TSerializable, file_handle: BinaryIO) -> None: |