3 ms·
> Why can't you add an index to a simple in-memory list? The index is already a "simple in-memory list", sorted. That's why it is expensive to mantain. > It w
by ElectricalUnion 4y ago
> Why can't you add an index to a simple in-memory list?
The index is already a "simple in-memory list", sorted. That's why it is expensive to mantain.
> It would be great if you could have a std::vector or Python list of plain old objects
Sort said Python list by the columns in your index.
> and then tell it to add an index (using a hashtable for example) on one or two of the fields.
Hashtable is another thing entirely, and designed for fast key retrieval at very high memory and CPU cost. If you can't afford a index you can't afford a Hashtable/dict either.
- bshipp 4y agoEvery time I've found myself heading down this rabbit hole of creating a faster Python list sort/search, I've inevitably realized that using an in-memory sqlite database is orders of magnitude faster and more flexible, especially once you start trying to mangle lists or sets with millions of elements. The added benefit is that you can also dump it to the drive if you have to prematurely end your task and resume it from the same place later. And it also supports indexes, both traditional and full-text searching. It's a lot easier to use a tool designed for the task instead of building one from scratch.