Skip to content

Commit

Permalink
small optimization of BytesIOPayload.size (#2129)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdarcet authored and asvetlov committed Jul 26, 2017
1 parent 153197f commit 91dc5b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion aiohttp/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ class BytesIOPayload(IOBasePayload):

@property
def size(self):
return len(self._value.getbuffer()) - self._value.tell()
p = self._value.tell()
l = self._value.seek(0, os.SEEK_END)
self._value.seek(p)
return l - p


class BufferedReaderPayload(IOBasePayload):
Expand Down

0 comments on commit 91dc5b7

Please sign in to comment.