Skip to content

Commit 65dab0e

Browse files
[PR #10038/6f4e9615 backport][3.11] Small speed up to StreamWriter.__init__ (#10039)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 3d2b829 commit 65dab0e

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

aiohttp/abc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ def filter_cookies(self, request_url: URL) -> "BaseCookie[str]":
195195
class AbstractStreamWriter(ABC):
196196
"""Abstract stream writer."""
197197

198-
buffer_size = 0
199-
output_size = 0
198+
buffer_size: int = 0
199+
output_size: int = 0
200200
length: Optional[int] = 0
201201

202202
@abstractmethod

aiohttp/http_writer.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class HttpVersion(NamedTuple):
3838

3939

4040
class StreamWriter(AbstractStreamWriter):
41+
42+
length: Optional[int] = None
43+
chunked: bool = False
44+
_eof: bool = False
45+
_compress: Optional[ZLibCompressor] = None
46+
4147
def __init__(
4248
self,
4349
protocol: BaseProtocol,
@@ -46,17 +52,7 @@ def __init__(
4652
on_headers_sent: _T_OnHeadersSent = None,
4753
) -> None:
4854
self._protocol = protocol
49-
5055
self.loop = loop
51-
self.length = None
52-
self.chunked = False
53-
self.buffer_size = 0
54-
self.output_size = 0
55-
56-
self._eof = False
57-
self._compress: Optional[ZLibCompressor] = None
58-
self._drain_waiter = None
59-
6056
self._on_chunk_sent: _T_OnChunkSent = on_chunk_sent
6157
self._on_headers_sent: _T_OnHeadersSent = on_headers_sent
6258

0 commit comments

Comments
 (0)