Roy Smith <[EMAIL PROTECTED]> writes: > This is true, but I'm generating the message being sent in very small > chunks (often as small as 4 bytes at a time), and typically need to flush a > packet out onto the network after a few dozen bytes. Maybe at most a few > hundred. I don't know of any networks with MTU's smaller than that. > Measurements show a 10-fold improvement in protocol throughput with large > packets vs. small ones. The only question is what's the most efficient way > in Python to generate the large packets.
Probably: build up the packet with cStringIO or with the array module instead of as a list of small strings. But if you time both versions I don't think it'll matter much. Python (at least CPython) simply will not be very fast no matter what you do. The overhead of building a large string (with ''.join, say) from a bunch of small ones isn't that big a deal compared with what you already lose in interpreter overhead running the application. -- http://mail.python.org/mailman/listinfo/python-list