Bug report
Bug description:
asyncio.StreamWriter.__init__ creates a _complete_fut Future and stores it on the instance:
# Lib/asyncio/streams.py
def __init__(self, transport, protocol, reader, loop):
self._transport = transport
self._protocol = protocol
assert reader is None or isinstance(reader, StreamReader)
self._reader = reader
self._loop = loop
self._complete_fut = self._loop.create_future()
self._complete_fut.set_result(None)
The StreamWriter class is used by functios such as: asyncio.open_connection, asyncio.start_server, asyncio.open_unix_connection, asyncio.start_unix_server. So the allocation of an unused future happens on every asyncio network connection
The attribute is not read anywhere in CPython. The project search returned only two lines in StreamWriter.__init__
Proposed change:
Drop the two _complete_fut lines:
def __init__(self, transport, protocol, reader, loop):
self._transport = transport
self._protocol = protocol
assert reader is None or isinstance(reader, StreamReader)
self._reader = reader
self._loop = loop
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
Bug description:
asyncio.StreamWriter.__init__creates a_complete_futFuture and stores it on the instance:The
StreamWriterclass is used by functios such as:asyncio.open_connection,asyncio.start_server,asyncio.open_unix_connection,asyncio.start_unix_server. So the allocation of an unused future happens on every asyncio network connectionThe attribute is not read anywhere in CPython. The project search returned only two lines in
StreamWriter.__init__Proposed change:
Drop the two
_complete_futlines:CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs