Move isinstance checks up a level when reading raw bytes
Closed this issue · 0 comments
greglucas commented
Just writing this down for my memory later, but no need to do anything with this now.
Here I think we could put these isinstance
checks outside this function so it is only checked once on the initial input stream and not every read.
if isinstance(source, io.BufferedIOBase):
byte_reader = source.read
elif isinstance(source, socket.socket):
byte_reader = source.recv
...
data = byte_reader(read_size_bytes)
Originally posted by @greglucas in #79 (comment)