The BufferedProtocol
for TCP has been implemented since Python 3.7.
class BufferedProtocol(BaseProtocol):
__slots__ = ()
def get_buffer(self, sizehint):
pass
def buffer_updated(self, nbytes):
pass
def eof_received(self):
pass
Likewise, considering Python supports socket.recvfrom_into
for UDP and readinto
for sys.stdin.buffer
, is it feasible to add support for “Buffered Datagram Protocols” and “Buffered Subprocess Protocol”?
class BufferedDatagramProtocol(BaseProtocol):
__slots__ = ()
def get_buffer(self, sizehint):
pass
def buffer_updated(self, nbytes, addr):
pass
def error_received(self, exc):
pass
class BufferedSubprocessProtocol(BaseProtocol):
__slots__ = ()
def get_buffer(self, sizehint):
pass
def buffer_updated(self, fd, nbytes):
pass
def pipe_connection_lost(self, fd, exc):
pass
def process_exited(self):
pass
Therefore, unnecessary data copies and memory allocation might be avoided, thereby resulting in noticeable performance improvement.