Skip to content

Commit

Permalink
[PR #10038/6f4e9615 backport][3.12] Small speed up to `StreamWriter._…
Browse files Browse the repository at this point in the history
…_init__` (#10040)

Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
patchback[bot] and bdraco authored Nov 25, 2024
1 parent 24eb11d commit 5e4ad95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions aiohttp/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ def filter_cookies(self, request_url: URL) -> "BaseCookie[str]":
class AbstractStreamWriter(ABC):
"""Abstract stream writer."""

buffer_size = 0
output_size = 0
buffer_size: int = 0
output_size: int = 0
length: Optional[int] = 0

@abstractmethod
Expand Down
16 changes: 6 additions & 10 deletions aiohttp/http_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class HttpVersion(NamedTuple):


class StreamWriter(AbstractStreamWriter):

length: Optional[int] = None
chunked: bool = False
_eof: bool = False
_compress: Optional[ZLibCompressor] = None

def __init__(
self,
protocol: BaseProtocol,
Expand All @@ -46,17 +52,7 @@ def __init__(
on_headers_sent: _T_OnHeadersSent = None,
) -> None:
self._protocol = protocol

self.loop = loop
self.length = None
self.chunked = False
self.buffer_size = 0
self.output_size = 0

self._eof = False
self._compress: Optional[ZLibCompressor] = None
self._drain_waiter = None

self._on_chunk_sent: _T_OnChunkSent = on_chunk_sent
self._on_headers_sent: _T_OnHeadersSent = on_headers_sent

Expand Down

0 comments on commit 5e4ad95

Please sign in to comment.