Skip to content

Consider using bytearray #58

@Poikilos

Description

@Poikilos

Maybe use bytearray in general (to replace int lists)

  • mutable alternative to bytes, similar functionality as int list
  • readable since is explicitly holding byte values and has related features, and for that reason also maps to other languages better (understandable example code; other languages have string features related to byte collections as well)
    • extend(ba: bytearray)
    • append(b: int) # no cast necessary
      • elements read as if it were list[int], but it has decode method like bytes
    • can cast directly from list[int] or bytes
    • cast cast directly to bytes
  • conversion is more direct (bytes(data[:byteCount]).decode("utf-8") or bytearray(data[:byteCount]).decode("utf-8") becomes data[:byteCount].decode("utf-8"))
    • slightly faster probably, or at least less code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions