Optimizing diffarray

I think it would indeed be useful to have unsafeIndex and unsafeSet functions, which just error when you use them on old versions of the list. That is a good suggestion. I have opened Issue #17 to track it.

Still, I think accessing older versions does not necessarily have to be very expensive. This removal of intermediate versions optimization already helps a bit. But I have been thinking about other ways to improve performance further.

For example, I also have another idea about copying after enough accesses have happened to off-set the cost (see Issue #10). If that works out as I hope, it could give O(1) amortized access to old versions.

Yeah, sorry, I meant “a regular linearly implemented array” instead of a Diff Array?
(i.e. why keep the diff if you’re using it linearly?)

You wouldn’t. Ideally I imagine a different type that can be a drop in replacement for the normal diff array that you would use when you care more about performance than code. This might force you to do some manual sequencing to ensure you’re really using only the newest array which would otherwise be masked by the diff functionality.

I would not be better to have opportunistic mutability?

Can you elaborate on your question? I think diff arrays are a kind of opportunistic mutability. What would the alternative that you have in mind look like?