1、import doctest doctest.testmod(moname) 2、单元测试模块 unittest 3、堆栈调试模块pdb
image.png
4 python -m pdb xx.py
5 性能统计信息:
python -m profile xx.py
python -m cProfile xx.py
6 测量时间
from timeit import timeit,repeat
timeit('math.sqrt(2)','import math') #计时
repeat('math.sqrt(2)','import math') #打印三次执行的时间
image.png
7 sys.getsizeof(xx) #查看xx内存占用大小
8 from dis import dis
dis(split) #反汇编
9 slots ??
image.png
10 使用函数式编程,使用类装饰器
image.png