
Python
文章平均质量分 77
huntzw
这个作者很懒,什么都没留下…
展开
-
Python是如何实现dictionary
原文地址:http://www.laurentluce.com/posts/python-dictionary-implementation/ 本文描述了Python是如何实现dictionary。dictionary是由主键key索引,可以被看作是关联数组,类似于STL的map。有如下的基本操作。1>>> d = {'a': 1, 'b': 2}翻译 2012-01-28 18:42:15 · 4386 阅读 · 0 评论 -
Map-reduce 矩阵
来自微博的题目: Map Reduce 矩阵。新的矩阵的值,是原来矩阵附近8个临近节点的均值。python代码实现:# input: element is the key value pair of matrix# type: [row, column, value, totle_row, totle_column]def mapper(elem):原创 2013-07-11 10:32:57 · 692 阅读 · 0 评论 -
Static method vs class method in Python
Pyhon中@static method和@class method对于刚接触的人而言,有很多迷茫的地方。随之,转载 2014-04-14 19:50:47 · 3011 阅读 · 0 评论 -
Is Python call-by-value or call-by-reference?
First of all, here are two pieces of codes:原创 2014-04-20 10:29:35 · 1828 阅读 · 0 评论 -
MetaClass in Python
Python总是让我们能够看到它的内部是如何实现的,qi转载 2014-06-05 19:22:51 · 820 阅读 · 0 评论 -
yield in Python
To understand what yield does, you must understand what generators are. And before generators come iterables.原创 2014-06-05 19:39:35 · 787 阅读 · 0 评论 -
蓄水池算法简介
从N个元素中随机抽取k个元素,但是N不定。每个元素抽取的概率是k/N。先选中前k个,从k+1到最后一个元素,以1/i (i = k+1, k+2, ... N)的概率选中第i个元素,并且随机替换一个原来选中的元素。 1 from random import Random 2 3 def RandomSelect(knum, rand=None): 4 selec原创 2013-07-04 10:51:29 · 926 阅读 · 0 评论