Hi,
I noticed that the default buffer size used in socket.recv() calls (or possibly in a related function within your project) is currently set to 4 bytes.
data = sock.recv(4) # currently used in code
Reading data in such small chunks is extremely inefficient, especially over TCP sockets. It results in many system calls and can significantly degrade performance for larger payloads or high-throughput scenarios.
💡 Recommendation
Please consider increasing the default buffer size to 4096 bytes (4 KB), which is a commonly used and well-balanced size for general-purpose I/O:
data = sock.recv(4096) # suggested
This change should lead to better performance without introducing compatibility issues.