News for hackers. Stuff that matters.
Re:What's New in Python 3.11? by dragonwriter on Monday June 27, 2022 @02:38AM (#31891315)
> But in general a “dict”, or if you really need an array, binary search, should be used. Where’s the one liner for that in python?

For dict/set hash lookup, O(1):

   x in s
For binary search on a sorted python list, it takes a standard library import (bisect), and the containment test is:

  (i:=bisect.bisect_left(a, x)) < len(a) and a[i] == x

There are no comments on this comment yet.