page / bt-source /panel /class /webauthn /helpers /byteslike_to_bytes.py
GGSheng's picture
feat: deploy Gemma 4 to hf space
a757bd3 verified
from typing import Union
def byteslike_to_bytes(val: Union[bytes, memoryview]) -> bytes:
"""
Massage bytes subclasses into bytes for ease of concatenation, comparison, etc...
"""
if isinstance(val, memoryview):
val = val.tobytes()
return bytes(val)