Speed surprises in reimplementing the .find() string method

In yesterday's entry , I mentioned that Iwas surprised by the relative performances of my three reimplementationsof the .find() string method.

The src[i:].startswith(sub) version was the slowest, and why isobvious in hindsight: it's summed up clearly in the first bit, where wecreate a big new string ( src[i:] ) on every iteration of the loop. Nowonder it's slow; creating big strings is slow in general, because


全方位批鬥大會

全方位批鬥大會

Keith之所以在公司裡犯眾憎,除了因為他但求就手而搞女秘書,還因為他是女皇的親信,奸的。女皇為了鞏固勢力,鏟除異己,於是收了Keith為公公,專門混進同事當中收風。譬如早前有女同事踢爆女皇打Botox,Keith知道

唔知自己想點, 淨係知自己唔想點

下文涉及個人情緒, 以部份廣東話寫出.

「唔知自己想點, 淨係知自己唔想點」, 確是現今廿零歲人既做人態度. 因為好多野唔到自己話事, 唔夠膽主宰自己命運, 無能力改變現狀之下, 只好退一步令自己唔會太輸蝕. 我係其中

An illustration of the speed advantage of Python builtins

As a followup to my entry on the two sorts of languages , I decided to actually tryimplementing the string .find() method in Python to see how muchslower it is. The Python version uses the brute force C style approach,roughly:

for i in range(0, len(src)-len(sub)+1):    if src[i:i+len(sub)] == sub:       return ireturn -1

I actually did three versions, each with a different


20080229 網摘 – 側側膊之國際影業

Fansite

HK


王若琳



有沒有聽過王若琳的歌?
最近我都在聽.
意想不到啊.
沒有人見人愛的樣子
但能唱這種歌
定位已很明顯
厲害啊


少扣帽子,再談spin doctor

搞文學的人最怕重複,重複是因為被扭曲和無回應。扣帽子和假溝通的麻煩在於,它令所有的東西重複。不少人search「spin doctor,spin doctor」到此,大概很難接受世上真有人這樣姓屈,光天化日把人家沒說過的話塞到人家口裡。 spin doctor, spin doctor

My likely Firefox 3 extensions

My current personal version of Firefox is more than a little bit behindthe times, so I've been looking at upgrading to Firefox 3 (I compilemy own version with various hacks, and it's easiest to build from thebleeding edge CVS sources). As a result, I spent part of today tryingvarious of my essential extensions to see which ofthem still work.

Here's the current state of affairs:

  • NoScript has beenupdated for the current Firefox 3 beta and works fine. It'

書報攤

(圖片來自 HKStories

這一陣子都沒有看別的漫畫,只買現在以潮珍版重出的《超霸世紀》,不是特別好看,只是一份情意結。這本書是逢星期三出版的,也算蠻搶手,因為書報攤對這些「經典書」,不會入很大量貨,通常都只會有四至


賣書之二(危樓狀態)


我最恨就是買重複書!
從上至下:

1. 《麻不甩》 ,鄒凱光著,輕鬆小品。是的,我什麼書都看。九成新,原價$68,現價25。這種書,最好就是買二手了。

2. 《「惡女」是這樣誕生的》 ,封面銀色反光,是為了反映我作