diff --git a/aiohttp/streams.py b/aiohttp/streams.py index d47ca014a1..1c95e65ad7 100644 --- a/aiohttp/streams.py +++ b/aiohttp/streams.py @@ -42,6 +42,9 @@ class EofStream(Exception): class AsyncStreamIterator(Generic[_T]): + + __slots__ = ("read_func",) + def __init__(self, read_func: Callable[[], Awaitable[_T]]) -> None: self.read_func = read_func @@ -59,6 +62,9 @@ async def __anext__(self) -> _T: class ChunkTupleAsyncStreamIterator: + + __slots__ = ("_stream",) + def __init__(self, stream: "StreamReader") -> None: self._stream = stream @@ -107,6 +113,25 @@ class StreamReader(AsyncStreamReaderMixin): """ + __slots__ = ( + "_protocol", + "_low_water", + "_high_water", + "_loop", + "_size", + "_cursor", + "_http_chunk_splits", + "_buffer", + "_buffer_offset", + "_eof", + "_waiter", + "_eof_waiter", + "_exception", + "_timer", + "_eof_callbacks", + "total_bytes", + ) + total_bytes = 0 def __init__( @@ -505,6 +530,9 @@ def _read_nowait(self, n: int) -> bytes: class EmptyStreamReader(StreamReader): # lgtm [py/missing-call-to-init] + + __slots__ = ("_read_eof_chunk",) + def __init__(self) -> None: self._read_eof_chunk = False @@ -573,6 +601,15 @@ def read_nowait(self, n: int = -1) -> bytes: class DataQueue(Generic[_SizedT]): """DataQueue is a general-purpose blocking queue with one reader.""" + __slots__ = ( + "_loop", + "_eof", + "_waiter", + "_exception", + "_size", + "_buffer", + ) + def __init__(self, loop: asyncio.AbstractEventLoop) -> None: self._loop = loop self._eof = False @@ -653,6 +690,8 @@ class FlowControlDataQueue(DataQueue[_SizedT]): It is a destination for parsed data. """ + __slots__ = ("_protocol", "_limit") + def __init__( self, protocol: BaseProtocol, limit: int, *, loop: asyncio.AbstractEventLoop ) -> None: