getsizeof的局限 python非内置数据类型的对象无法用sys.getsizeof()获得真实的大小,例: import networkx as nx import sys G = nx.Graph() l = [i for i in xrange(10000)] print "size of l:", sys.getsizeof(l) G.add_nodes_from(l) print "size of graph:", sys.getsizeof(G)
不可或缺的函数,在Go中定义函数的方式如下: func (p myType ) funcName ( a, b int , c string ) ( r , s int ) { return } 通过函数定义,我们可以看到Go中函数和其他语言中的共性和特性 共性 关键字——func 方法名——funcName 入参——— a,b int,b string 返回值—— r,s int 函数体—— {} 特性 Go中函数的特性是非常酷的,给我们带来不一样的编程体验. 为特定类型定义函数,即为类型对象