查看源代码(CPython的源代码,对于其他实现而言可能会有不同的行为),脚本的奇怪输出变得显而易见:
saved_ob_size = Py_SIZE(self);saved_ob_item = self->ob_item;saved_allocated = self->allocated;Py_SIZE(self) = 0;
注释说明了一切:开始排序时,列表将被清空。好吧,在外部观察者的眼中,它是“空的”。
我非常喜欢“堆芯工厂”一词。
还比较:
b = ['b','e','f','d','c','g','a']f = 'check this'def m(i): print i, b, f return Noneb = sorted(b, key= m)print b



