Encode a dictionary value. Args: datum: The dictionary value to encode. Returns: The encoded bytes.
(datum: dict)
| 121 | return b"t%se" % b"".join(encode(element) for element in datum) |
| 122 | |
| 123 | def encode_dict(datum: dict) -> bytes: |
| 124 | """ |
| 125 | Encode a dictionary value. |
| 126 | |
| 127 | Args: |
| 128 | datum: The dictionary value to encode. |
| 129 | |
| 130 | Returns: |
| 131 | The encoded bytes. |
| 132 | """ |
| 133 | return b"d%se" % b"".join( |
| 134 | b"%s%s" % (encode(key), encode(value)) for key, value in datum.items() |
| 135 | ) |
| 136 | |
| 137 | ENCODERS: dict[type, Callable[[Any], Any]] = { |
| 138 | type(None): encode_none, |