python flask 部分源码理解

#偏函数
from functools import partial
def demo(a,*args):
print(a)
print(args)

par_fun = partial(demo,1)
par_fun(3,3,4,5)



线程安全(local)空间换时间
from threading import local
from threading import Thread
from time import sleep


class Foo(local):
pass


foo = Foo()


def demo(i):
foo.i = i
sleep(1)
print("------")
print(foo.i, i)




for i in range(20):
th = Thread(target=demo,args=(i,))
th.start()
posted @ 2019-10-08 23:05  Mr_Smith  阅读(154)  评论(0编辑  收藏  举报