How do I compare python functions in terms of performance?

前端 未结 2 1347
没有蜡笔的小新
没有蜡笔的小新 2021-02-20 08:46

I have written 2 functions doing the exact same thing, but I don\'t know which one is faster and better. How do I compare these 2 functions to see which one is better in terms o

2条回答
  •  清歌不尽
    2021-02-20 09:15

    Once you've found out which function is faster using the timeit module, you can also get more precise details of where the differences are by using the profile module.

提交回复
热议问题