Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: accessing array by index very slow



On Sun, Apr 16, 2023 at 11:04 AM Stephane Chazelas
<stephane@xxxxxxxxxxxx> wrote:
>
> Accessing array elements via their index is very slow,
> especially for large index values.

Indeed, access to array elements is O(N) in zsh instead of O(1) that
one might expect. The same goes for strings, even with no_multibyte.
This makes computation-heavy code incredibly slow. If someone can fix
this, they'll have my eternal gratitude.

On the plus side zsh has fast hashtables (closed hashing with
quadratic probing). Bash's implementation is a lot slower (it's
node-based).

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author