Re: socket send O(N**2) complexity

2009-09-22 Thread Antoine Pitrou
exarkun at twistedmatrix.com writes: To the OP, you can get view-like behavior with the buffer builtin. And, on Python 3 (or even the 2.7 in development), you can use the memoryview builtin for similar effect. Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list

Re: socket send O(N**2) complexity

2009-09-22 Thread Nobody
On Mon, 21 Sep 2009 16:33:08 -0400, Jack Diederich wrote: AIUI, as a python string is imutable, a slice of a string is a new string which points (C char *) to the start of the slice data and with a length that is the length of the slice, about 8 bytes on 32 bit machine. Not in CPython.

Re: socket send O(N**2) complexity

2009-09-22 Thread Jack Diederich
On Tue, Sep 22, 2009 at 7:25 PM, Nobody nob...@nowhere.com wrote: On Mon, 21 Sep 2009 16:33:08 -0400, Jack Diederich wrote: AIUI, as a python string is imutable, a slice of a string is a new string which points (C char *) to the start of the slice data and with a length that is the length of

Re: socket send O(N**2) complexity

2009-09-22 Thread Steven D'Aprano
On Wed, 23 Sep 2009 00:25:52 +0100, Nobody wrote: On Mon, 21 Sep 2009 16:33:08 -0400, Jack Diederich wrote: AIUI, as a python string is imutable, a slice of a string is a new string which points (C char *) to the start of the slice data and with a length that is the length of the slice,

socket send O(N**2) complexity

2009-09-21 Thread Zac Burns
The mysocket.mysend method given at http://docs.python.org/howto/sockets.html has 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

Re: socket send O(N**2) complexity

2009-09-21 Thread Mike
On Sep 21, 2:03 pm, Zac Burns zac...@gmail.com wrote: The mysocket.mysend method given athttp://docs.python.org/howto/sockets.htmlhas 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

Re: socket send O(N**2) complexity

2009-09-21 Thread Rob Williscroft
Zac Burns wrote in news:mailman.211.1253559803.2807.python-l...@python.org in comp.lang.python: The mysocket.mysend method given at http://docs.python.org/howto/sockets.html has an (unwitting?) O(N**2) complexity for long msg due to the string slicing. I've been looking for a way to

Re: socket send O(N**2) complexity

2009-09-21 Thread exarkun
On 08:00 pm, r...@freenet.co.uk wrote: Zac Burns wrote in news:mailman.211.1253559803.2807.python- l...@python.org in comp.lang.python: The mysocket.mysend method given at http://docs.python.org/howto/sockets.html has an (unwitting?) O(N**2) complexity for long msg due to the string slicing.

Re: socket send O(N**2) complexity

2009-09-21 Thread Jack Diederich
On Mon, Sep 21, 2009 at 4:00 PM, Rob Williscroft r...@freenet.co.uk wrote: AIUI, as a python string is imutable, a slice of a string is a new string which points (C char *) to the start of the slice data and with a length that is the length of the slice, about 8 bytes on 32 bit machine. Not

Re: socket send O(N**2) complexity

2009-09-21 Thread Rob Williscroft
wrote in news:mailman.216.1253565002.2807.python-l...@python.org in comp.lang.python: Niether of the CPython versions (2.5 and 3.0 (with modified code)) exibited any memory increase between allocated 1 meg + and end You bumped into a special case that CPython optimizes. s[:] is s. If

Re: socket send O(N**2) complexity

2009-09-21 Thread Zac Burns
On Mon, Sep 21, 2009 at 2:10 PM, Rob Williscroft r...@freenet.co.uk wrote:  wrote in news:mailman.216.1253565002.2807.python-l...@python.org in comp.lang.python: Niether of the CPython versions (2.5 and 3.0 (with modified code)) exibited any memory increase between allocated 1 meg + and end