The Runcible Blog

Posts with tag 'Python'

Phickle

 Before joining Tabblo I used Gallery for sharing photos online.  Although I haven't used it much since, spammers have been hammering the albums with comment spam.  I didn't realize the extent of it until today, and I wanted to clear out the noise.  Unfortunately, the administration interface doesn't make deleting 1000 comments easy.  I started to make a script to help me delete them. Gallery uses a big serialized php array to store the album data and the comments, which ......
[ Read More ]

Is exception handling slow?

Ned's post about "human sorting" lists lead to the inevitable comments from people who want to write the most succinct solution to the problem. Among them was the remark that "exception handling is slow." Ned asked me why it was assumed that exception handling was so slow, and I replied that it isn't (based on some of the remarks about improvements in exception handling in Python 2.5). I had no real evidence of the overhead from catching exceptions, so I ......
[ Read More ]

removing dupes

I came across a post about the quickest way to remove duplicates from a python list. This particular problem seems to crop up often, and I've noticed a huge slow down when doing something like: new_list = [] for i in old_list: if i not in new_list: new_list.append(i) I never took the time to benchmark different techniques like Peter did, though. It's interesting to see that: {}.fromkeys(seq).keys() is the fastest method, but only a hair faster than the conceptually simpler: ......
[ Read More ]

PyStone Confirms it: MacBook Pro Wins

PyStone results (best of 4 tries for each): AMD Sempron 1.5Ghz running FreeBSD 6.0: 29090.9 pystones/sec Dual G5 2Ghz desktop running OS 10.4.6: 30120.5 pystones/sec Dual G5 2Ghz Xserve running OS 10.3.9: 11261.3 pystones/sec Macbook Pro 2Ghz running OS 10.4.6: 45871.6 pystones/sec (1.5x faster than G5) Yes, I'm sure this isn't a scientific test. The Xserve failed miserably. Even though it did have a light load, I'm guessing OS 10.3.9 played a part in its poor performance. I'm also not ......
[ Read More ]