Why using local variables is fast in Python

One piece of Python optimization lore is that access to localvariables is very fast, so if you repeatedly refer to something in aloop in a function you can optimize it by copying it to a localvariable first (this often comes up when you are repeatedly calling afunction). This fast access comes about because of some implementationdetails in CPython.

The CPython interpreter doesn't run Python code directly, but firstcompiles it to bytecode for a relatively simple stack-based virtualmachine. You can see the actual


20051112網摘 – 普選鳳凰

Logo

NANA

Movie

Culture


中年.《黑社會》

在表現的層面上,《黑社會》不過不失——燈光漂亮,譚家明的剪接暗湧處處。 在語言層面,對我來說,進入它的語境,比很多詩都要更花精神。

可 我卻總覺得有種叔父氣湧面而來。那種彷彿看穿一切的「a又係咁,非a又係咁

階級矛盾如何調和——《怪物》

在驚悚片這種電影類型中,恐怖的他者是驚嚇元素的重要來源。而尤其當驚悚片嘗試為恐怖的他者尋找行動的原因之時,就開始把自己與現實中的階級衝突連繫了起來。

共在的恐懼

半舊的港產片《救命》作為驚悚片大概算是平平

face to face

20051111網摘 – Sony 大件事

IT News/Reviews

Free Resources


A capella Express

aexpress

A Capella Express 上星期來港表演,沒有時間看,但有時間去一個他們於文化中心辦的小型 workshop,也藉此可以一聽他們的 Live Performance,印象十分深刻。

六人都已經十分有默契,他們的 Harmony 唱得非常地完美,完全有被溶化的感覺。他們的老大是唱低音,


The importance of understanding Python's implementation

Joel Spolsky likes to talk about leaky abstractions ,how the lower level details underneath abstractions inevitably leakthrough and affect your work with those abstractions. High levellanguages like Python are no exception, because how their abstractionsare implemented has significant effects on how fast different sorts ofcode will run.

For instance, let's take lists and tuples, both of which CPythonimplements as arrays of objects. This has a number of consequences:

  • indexing a list element is cheap, and all list elements are equallycheap to access.

How doing relative name DNS lookups can shoot you in the foot

DNS-based host name lookups can be what I'll call 'relative', whichlook for the host name inside some domain, or 'absolute', whichassumes that the host name is fully qualified and starts right fromthe root DNS. (For clarity, absolute names are often written with atrailing '.'; this can often be used to make resolver libraries treatthem as absolute.)

Once upon a time, we had an interesting mail explosion. The campuswide mail servers started sending our


沒有地獄的 Doom

doom

Doom 毀滅戰士》又是另一齣由同名遊戲改編的電影,我當年也有玩 Doom 系列,到前些年推出的第三集也有捧場。《Doom》屬於殿堂級的遊戲作品,在技術和遊戲性上都有顯注的突破。在遊戲裏,只要夠好玩,大部份玩家都不會理會遊


20051109網摘 – 我們不要現代義和團

Comments

Web Development