What algorithm is used when using the in operator in python to search a list?

前端 未结 2 1388
忘掉有多难
忘掉有多难 2021-02-02 14:26

When using the \'in\' operator to search for an item in a list e.g.

if item in list:
  print item

What algorithm is used to search for this ite

2条回答
  •  甜味超标
    2021-02-02 14:51

    If list is a literal list, Python 3.2+ will take a faster approach: http://docs.python.org/dev/whatsnew/3.2.html#optimizations

提交回复
热议问题