Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/PIL/_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

__lazy_modules__ = {"struct"}

from struct import pack, unpack_from
from struct import unpack_from


def i8(c: bytes) -> int:
return c[0]


def o8(i: int) -> bytes:
return bytes((i & 255,))
return (i & 255).to_bytes()


# Input, le = little endian, be = big endian
Expand Down Expand Up @@ -100,16 +100,16 @@ def i32be(c: bytes, o: int = 0) -> int:

# Output, le = little endian, be = big endian
def o16le(i: int) -> bytes:
return pack("<H", i)
return i.to_bytes(2, "little")


def o32le(i: int) -> bytes:
return pack("<I", i)
return i.to_bytes(4, "little")


def o16be(i: int) -> bytes:
return pack(">H", i)
return i.to_bytes(2, "big")


def o32be(i: int) -> bytes:
return pack(">I", i)
return i.to_bytes(4, "big")