socket send O(N**2) complexity

Mike hennebry at
Mon Sep 21 21:47:02 CEST 2009

On Sep 21, 2:03 pm, Zac Burns <zac... at> wrote:
> The mysocket.mysend method given at an (unwitting?) O(N**2)
> complexity for long msg due to the string slicing.
> I've been looking for a way to optimize this, but aside from a pure
> python 'string slice view' that looks at the original string I can't
> think of anything. Perhaps start and end keywords could be added to
> send? I can't think of a reason for the end keyword,  but it would be
> there for symmetry.

for ch in msg: add to current buffer or start another buffer
for buf in buffers: send(...buf)

More information about the Python-list mailing list