> 4\. `nav` should probably use some better algorithm

I feel like long-term rather than a linked list, you would be better off 
building around something like:
    
    
    type
      HunkSeq*[T] = object
        caps, lens: seq[int]
        datas: seq[UncheckedArray[T]]
    
    
    Run

It's only 2 regular `seq` and there is no long-chains of pointer chasing. You 
could have a cumulative index array for fast `[]`, etc., etc.

And `HunkSeq` is a bit more explicit about the non-copying "sense" of 
"stability". I had no idea what `StableSeq` meant until I read your post. I 
thought it might be a kind of file-resident ("stable storage") or [persistent 
thing](https://en.wikipedia.org/wiki/Persistent_data_structure). 
NonCopyingOnGrowthSeq is too much of a mouthful, IMO.

Since this is fundamentally an optimization, I understand the expensive copy 
question, but I think it's probably best to be as drop-in compatible as 
possible. There is a strong argument for a "performance warning", though (both 
here and probably in other Nim collections).

`"append"` might confuse Python people. A (shorter!) alternative might be 
`ensureAdd`, although I would personally keep the operations of 
`ensureCap|ensureRoom|setLen|grow` and `add` separate, at least initially. As 
kind of telegraphed by the existing code above, `add` is already kind of 
`ensureAdd`.

Reply via email to