basalt icon indicating copy to clipboard operation
basalt copied to clipboard

Add Collection.reserve() to avoid uneeded resizing

Open Benny-Nottonson opened this issue 1 year ago • 0 comments

This PR fixes a number of issues with Collection and additionally adds .reserve() and .reserve_additional() to allow Model to reserve and allocate memory at creation, rather than resizing when needed as append gets called.

Some additional notes on collection:

  • Ideally this could be simplified to just be Dict, but in Dicts current form, this is ridiculously slow.
  • Keeping the list sorted by key and using binary search for faster access takes about the same time due to generally small list size
  • DType.uint32 might be larger than needed for the use case in Basalt, and realistically could be a user specified value, or long term, a value that we can autotune for.

Benny-Nottonson avatar May 19 '24 22:05 Benny-Nottonson