Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #10038/6f4e9615 backport][3.11] Small speed up to StreamWriter.__init__ #10039

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading