[Twisted-Python] twisted socksv4 proxy

Bob Ippolito bob at redivi.com
Wed Sep 24 18:30:06 EDT 2003

yay for profiling :)

oh wow that's definitely going to be slow:
             f.write(string.join(map(lambda x:'%02X'%ord(x),p),' ')+' ')

It's just that one line of code killing all your performance :)  That  
little loop could (probably) be done MUCH more efficiently by using  
something like:
map('%02X'.__mod__, struct.unpack('B' * len(data), data))

instead of doing it 16 at a time with lambda and ord.

Just out of curiosity, how does your performance and CPU utilization  
look now, without logging on?  I don't hear much about Twisted and  
performance.. Maybe it's not bad enough to complain about, or perhaps  
nobody has deployed twisted apps that see excessive load, but I haven't  
heard much either way.


On Wednesday, Sep 24, 2003, at 17:59 America/New_York, Yun Mao wrote:

> It looks like the log function in line 141 is doing the silly thing. I
> disabled the log and it works fine now. :)
> On Wed, 24 Sep 2003, Yun Mao wrote:
>> I've put the profiling result to
>> http://www.twistedmatrix.com/users/roundup.twistd/twisted/file87/ 
>> bugreport.txt
>> Forgot to mention the env: gentoo, python 2.2.3, twisted 1.0.7

More information about the Twisted-Python mailing list