Why is processing a sorted array not faster than an unsorted array in Python?

后端 未结 5 2238
说谎
说谎 2021-02-13 10:27

In this post Why is processing a sorted array faster than random array, it says that branch predicton is the reason of the performance boost in sorted arrays.

But I just

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-13 10:36

    Two reasons:

    • Your array size is much too small to show the effect.
    • Python has more overhead than C so the effect will be less noticeable overall.

提交回复
热议问题