(data: ReadBuffer, tag: Tag)
| 329 | |
| 330 | |
| 331 | def read_literal(data: ReadBuffer, tag: Tag) -> int | str | bool | float: |
| 332 | if tag == LITERAL_INT: |
| 333 | return read_int_bare(data) |
| 334 | elif tag == LITERAL_STR: |
| 335 | return read_str_bare(data) |
| 336 | elif tag == LITERAL_FALSE: |
| 337 | return False |
| 338 | elif tag == LITERAL_TRUE: |
| 339 | return True |
| 340 | elif tag == LITERAL_FLOAT: |
| 341 | return read_float_bare(data) |
| 342 | assert False, f"Unknown literal tag {tag}" |
| 343 | |
| 344 | |
| 345 | # There is an intentional asymmetry between read and write for literals because |