Open TysonAndre opened 2 years ago
Those are technically logarithmic, the log depth is just small for realistic amounts of memory (only several times slower than arrays in that language).
Transients are a lot less convenient in php.
PHP's gc algorithm also poses unique problems - gc will be slow if a lot of immutable collections reference the same array
Something simpler that would have okay typical-case but worse worst-case performance: Storing references to at most 4 zend_array
(packed list) instances/ImmutableList/individual zvals internally (and ranges of those arrays) may work for some common use case, for the head/tail for appending/prepending, combining them in place/freeing internally when reference counts drop to 1
Google searching mentioned Relaxed Radix Binary Trees, an immutable datastructure surprisingly claiming performance near arrays in most operations. https://hypirion.com/musings/thesis https://github.com/hyPiRion/c-rrb