Some of my assumptions about Python object allocation

In a reddit comment thread I was accurately dinged for being a bit casual in how I talked aboutobject allocation at the end of my previous entry . As the comment notes, calling ' .setdefault(k,[]) ' creates and throws away a new object each time the key alreadyexists, just as ' .setdefaults(k, SomeClass()) ' would.

Well, sort of. One of the things I assume about Python is thatallocating and freeing new empty instances of built-in types


男人最痛算這種

(以下又係真人真事,事發現場是冠男軒,時間是六點幾的飲早茶時段,一支公去呢d地方例必要搭枱,搭枱的奧妙之處就在於你永遠唔知道同你同枱嘅人會係邊一類人,今次同我同枱係兩個男人)

男人A(佢好勞氣):佢老味

變種數獨

數獨遊戲有很多變種,今天玩了一隻叫「總和數獨」,題目看上去是這樣子的:

小數字是虛線包圍範內的總和,玩的時候不能像普通數獨遊戲直接推斷,而是要將數字的可能性寫下,計算一下可能的加數組合,跟據條件去除可能

Continue reading...

愛在海嘯怒吼時

愛在海嘯怒吼時

初四第一天開工收到風,有間大型律師行牛年第一件事就是裁員!「女皇」按傳統巡迴公司派利是,辦公室裡隨著她那高跟鞋的咯咯聲而昇起了一種白色恐怖,不知她要派的究竟是紅信封還是大信封。

雖說那是第

報應

多年以來,聖誕或新年倒數時,我常常在各舊區的狹小雞籠公園,就著昏黃的燈光看書,與公園裡的老人作伴,或者只得我一個人。非常怡然自得。走在街上,背向節日的人潮,人像擺脫線軸的鳶子一樣泠然清醒。

有咁耐風流。

到底有誰能夠告訴我

為何即月期金是$34.54,下月卻是$42.29。揸長倉的我,轉倉的話不就是白白不見了$7.5?
不是7個半,
是$7500,
美金。

Video on acid/alkaline on CNN


The accumulator mini-pattern and .setdefault()

What I'm going to call the accumulator (mini-)pattern is a commonoperation when summarizing a stream of data: you have some keys, whichcan repeat, and you want to accumulate some data each time each keycomes up, to count it or sum it all up or keep a list of all of the datafor each key.

In pretty much every language that has them, this pattern is done withdictionaries (or hashes or the language's equivalent). In Python, thiscreates


梁文道本新書好睇到爆


幾日前在邊度有書買了梁文道的"常識"
真的非常好看
有視野有深度更厲害的是有理想
讀了幾篇已經不停叫好
絕對值得向喜歡讀書喜歡思考喜歡分析社會問題的朋友推薦
廢話少說
總之這本書真係好睇到爆啦


大娛樂家-(第35集)-鹹豬手 /黄長發


https://www.hkreporter.com/myradio/channel_list.php?channelid=101