This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregory.p.smith
Recipients berker.peksag, gregory.p.smith, orsenthil, terry.reedy, zveinn
Date 2021-03-05.22:13:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
FYI another common socket idiom for this, specifically added for use in old HTTP 1.x servers building up responses, is setting and clearing the TCP_CORK (Linux) or TCP_NOPUSH (FreeBSD, and maybe macos? [buggy?]) socket option before and after the set of send()s you want to be optimally buffered into packets.

A more modern approach (often used with TCP_CORK) is not to build up a single buffer at all.  Instead use writev().  os.writev() exists in Python these days.  It limits userspace data shuffling in the normal case of everything getting written.

Unfortunately... this old http client code and API isn't really setup for that.  Everything is required to go through the HTTPConnection.send method.  And the send method is not defined to take a list of bytes objects as writev() would require.  

So for this code, the patch we want is just the joined bytes or BytesIO. It is the simple better change that works everywhere without getting into platform specific idioms.

For modern best practices I'd look to the async frameworks instead of this older library.
Date User Action Args
2021-03-05 22:13:24gregory.p.smithsetrecipients: + gregory.p.smith, terry.reedy, orsenthil, berker.peksag, zveinn
2021-03-05 22:13:24gregory.p.smithsetmessageid: <>
2021-03-05 22:13:24gregory.p.smithlinkissue43332 messages
2021-03-05 22:13:23gregory.p.smithcreate