Saturday, June 1, 2019

fastest list index searching

Someone was looking for fastest list index searching (in Python) in stackoverflow. There are only four elements in the list, still it was as issue for him, as it was used in an inner-loop and the profiler identified that, this part was executing the most. He tried several approaches.1. This is the most obvious one:if value in mylist: return mylist.index(value)Here the problem is, in the condition used in if, it takes O(n) time to check if the value is in the list, and the return statement... Original Source

https://codango.com/fastest-list-index-searching/

I am happy to share this resource that we found. The content displayed on this page is property of its original author or their organization.

No comments:

Post a Comment