a里面的测试表明了一个问题,定态分配的list快过列表推导式快过append重复调用. 这说明有的时候用列表推导式而不是append可以加速代码.
然后是静态生成. 理论上说,在任何情况下,这个都比列表推导式和append快,而且实际上就是快. 这很好理解,静态生成不需要扩张大小,尤其是list的大小重分配是一个很频繁的问题.
列表推导式和append之间关系
def join3(n):
b = []
for i in xrange(n): b.append(a[i])
# return ''.join(b)
def join4(n):
b = [a[i] for i in xrange(n)]
# return ''.join(b)
for n in xrange(1, 40, 2):
➥阅读更多
2013-05-28
Think
CPyUG
Python
Pythonic
概述
[5.25]Google I/O review 大会中山大学珠海校区行!-)
统计:
- G+报名 46 人
- 到场 42 人
- 有两名远道广州下来的同学
- 以及从隔壁北理工组团过来的同学!
➥阅读更多
2013-05-25
Events
gdg
sysu
event
summary
- hi GDG guys
- Cnglish again!
- i’m Zoom.Quiet, come from China, as GDG ZhuHai Organizer
- my Barcamp topic is:
- base ‘L10N’ make GDG chapters
- and pay attention, my slides is base s5,its pure html page
- so had released into internat
- thit is the URL
- http://zoomquiet.org/res/s5/130512-gdgsummit/
Zoom.Quiet
- yep,i know the Zoom.Quiet is error name
- but again,its my realy NikName
- and base the error name , i hold the global unique id !
- so the logo is show about what my error name realy means
disclaimer
➥阅读更多
2013-05-13
Think
gdg
google
usa
speech
summit