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

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

2009-09-22 Thread Jack Diederich
On Tue, Sep 22, 2009 at 7:25 PM, 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 slic

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 CPy

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

2009-09-22 Thread Antoine Pitrou
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-21 Thread Zac Burns
On Mon, Sep 21, 2009 at 2:10 PM, Rob Williscroft 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" >> >> Yo

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.

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

2009-09-21 Thread Jack Diederich
On Mon, Sep 21, 2009 at 4:00 PM, Rob Williscroft 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. Whi

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. I

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 op

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

2009-09-21 Thread Mike
On Sep 21, 2:03 pm, Zac Burns 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 slice view

Re: socket send

2009-07-31 Thread Francesco Bochicchio
On Jul 30, 10:16 pm, "Jan Kaliszewski" wrote: > 30-07-2009 o 12:29:24 Francesco Bochicchio wrote: > > > On Jul 30, 5:52 am, NighterNet wrote: > >> I am trying to figure out how to send text or byte in python 3.1. I am > >> trying to send data to flash socket to get there. I am not sure how to >

Re: socket send

2009-07-30 Thread Jan Kaliszewski
30-07-2009 o 12:29:24 Francesco Bochicchio wrote: On Jul 30, 5:52 am, NighterNet wrote: I am trying to figure out how to send text or byte in python 3.1. I am trying to send data to flash socket to get there. I am not sure how to work it. buff= 'id=' , self.id , ':balive=False\n' clientSock.

Re: socket send

2009-07-30 Thread Jan Kaliszewski
30-07-2009 o 05:52:06 NighterNet wrote: I am trying to figure out how to send text or byte in python 3.1. I am trying to send data to flash socket to get there. I am not sure how to work it. buff= 'id=' , self.id , ':balive=False\n' clientSock.send(buff); And what is the problem? *j -- Jan

Re: socket send

2009-07-30 Thread Francesco Bochicchio
On 30 Lug, 18:06, NighterNet wrote: > On Jul 30, 6:56 am, "Mark Tolonen" wrote: > > > > > > > "NighterNet" wrote in message > > >news:55aba832-df6d-455f-bf34-04d37eb06...@i4g2000prm.googlegroups.com... > > > >I am trying to figure out how to send text or byte in python3.1. I am > > > trying to s

Re: socket send

2009-07-30 Thread NighterNet
On Jul 30, 6:56 am, "Mark Tolonen" wrote: > "NighterNet" wrote in message > > news:55aba832-df6d-455f-bf34-04d37eb06...@i4g2000prm.googlegroups.com... > > >I am trying to figure out how to send text or byte in python3.1. I am > > trying to send data to flashsocketto get there. I am not sure how t

Re: socket send

2009-07-30 Thread Mark Tolonen
"NighterNet" wrote in message news:55aba832-df6d-455f-bf34-04d37eb06...@i4g2000prm.googlegroups.com... I am trying to figure out how to send text or byte in python 3.1. I am trying to send data to flash socket to get there. I am not sure how to work it. buff= 'id=' , self.id , ':balive=False\

Re: socket send

2009-07-30 Thread Francesco Bochicchio
On Jul 30, 5:52 am, NighterNet wrote: > I am trying to figure out how to send text or byte in python 3.1. I am > trying to send data to flash socket to get there. I am not sure how to > work it. > > buff= 'id=' , self.id , ':balive=False\n' > clientSock.send(buff); Try putting a 'b' before the co

Re: socket send help

2009-01-07 Thread Bryan Olson
Gabriel Genellina wrote: James Mills escribió: Bryan Olson wrote: I thought a firewall would block an attempt to bind to any routeable address, but not to localhost. So using INADDR_ANY would be rejected. No. My understanding is that firewalls block network traffic, not system calls. This

Re: socket send help

2009-01-06 Thread Gabriel Genellina
En Mon, 05 Jan 2009 22:59:46 -0200, James Mills escribió: On Tue, Jan 6, 2009 at 10:49 AM, Bryan Olson wrote: I thought a firewall would block an attempt to bind to any routeable address, but not to localhost. So using INADDR_ANY would be rejected. No. My understanding is that firewalls b

Re: socket send help

2009-01-05 Thread James Mills
On Wed, Dec 24, 2008 at 3:59 PM, greyw...@gmail.com wrote: (snip) > If I run testserver.py via the cmd prompt in Windows XP and then the > testclient.py program, I get the following error: > > Traceback (most recent call last): > File "C:\Python30\testclient.py", line 12, in >s.send('Hello

Re: socket send help

2009-01-05 Thread James Mills
On Tue, Jan 6, 2009 at 10:49 AM, Bryan Olson wrote: >> I thought a firewall would block an attempt to bind to any routeable >> address, but not to localhost. So using INADDR_ANY would be rejected. No. > My understanding is that firewalls block network traffic, not system calls. This is correct.

Re: socket send help

2009-01-05 Thread Bryan Olson
Gabriel Genellina wrote: Bryan Olson escribió: Gabriel Genellina wrote: greyw...@gmail.com escribió: [...] A simple server: from socket import * myHost = '' Try with myHost = '127.0.0.1' instead - a firewall might be blocking your server. Just a nit: I'd say the reason to use '127.0.0.1

Re: socket send help

2009-01-05 Thread Gabriel Genellina
En Sat, 03 Jan 2009 21:44:34 -0200, Bryan Olson escribió: Gabriel Genellina wrote: greyw...@gmail.com escribió: [...] A simple server: from socket import * myHost = '' Try with myHost = '127.0.0.1' instead - a firewall might be blocking your server. Just a nit: I'd say the reason to

Re: socket send help

2009-01-03 Thread Bryan Olson
Gabriel Genellina wrote: greyw...@gmail.com escribió: [...] A simple server: from socket import * myHost = '' Try with myHost = '127.0.0.1' instead - a firewall might be blocking your server. Just a nit: I'd say the reason to use '127.0.0.1' instead of the empty string is that a firewall

Re: socket send help

2008-12-25 Thread Chris Rebert
On Thu, Dec 25, 2008 at 10:08 PM, greyw...@gmail.com wrote: > Hi again, > > I've done some more playing around with socket and socketserver and > have discovered I can send strings or lists with socket.send() by > converting to bytes. But lists with strings in them or dicts can't be > converted b

Re: socket send help

2008-12-25 Thread greyw...@gmail.com
Hi again, I've done some more playing around with socket and socketserver and have discovered I can send strings or lists with socket.send() by converting to bytes. But lists with strings in them or dicts can't be converted by bytes(). How can I send those? One idea I initially tried was to set

Re: socket send help

2008-12-24 Thread greyw...@gmail.com
Chris & Gabriel, Thank you so much. My simple example now works. It was very frustrating that even the simple example didn't work, so your help is most appreciated. b'hello world' was the key. As for the error, I do still get it with 3.0 final so I'll go ahead and report it. John. On Dec 24,

Re: socket send help

2008-12-23 Thread Gabriel Genellina
En Wed, 24 Dec 2008 03:59:42 -0200, greyw...@gmail.com escribió: New guy here. I'm trying to figure out sockets in order to one day do a multiplayer game. Here's my problem: even the simplest examples don't work on my computer: A simple server: from socket import * myHost = '' Try with

Re: socket send help

2008-12-23 Thread Chris Rebert
On Tue, Dec 23, 2008 at 9:59 PM, greyw...@gmail.com wrote: > Hi everyone, > > New guy here. I'm trying to figure out sockets in order to one day do > a multiplayer game. Here's my problem: even the simplest examples > don't work on my computer: > > A simple server: > > from socket import * > my