Is there a faster alternative to python dict that also supports binary search on…
- User
Is there a faster alternative to python dict that also supports binary search on indices, for example i need to find the first row with index>3.5 very rapidly, I need it for data science so every row needs to contain a tuple of multiple variables
Assistant
There are a few faster alternatives to the built-in Python dict for key-value lookup, especially if you need ordered access. Some options to consider:
-
blist: A list-dict hybrid that allows binary search over ordered keys. Supports multiple values per key. Can find the first key greater than a value withbisect_left. -
OrderedDict: Remembers the insertion order of keys. Supports bisect search via the module. Slower than blist but uses standard dict API.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.