From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: accessing array by index very slow
Date: Sun, 16 Apr 2023 11:10:12 +0200 [thread overview]
Message-ID: <CAN=4vMouxgQNP=sfrXDhvtUkgLZgkDd6Z3GZX04rHGOhDwihpg@mail.gmail.com> (raw)
In-Reply-To: <20230416090342.dztvzcnzpbyukgfq@chazelas.org>
On Sun, Apr 16, 2023 at 11:04 AM Stephane Chazelas
<stephane@chazelas.org> 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.
next prev parent reply other threads:[~2023-04-16 9:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-16 9:03 Stephane Chazelas
2023-04-16 9:10 ` Roman Perepelitsa [this message]
2023-04-16 9:19 ` Sebastian Gniazdowski
2023-04-16 15:27 ` Bart Schaefer
2023-04-16 22:03 ` Mikael Magnusson
2023-04-18 2:43 ` Bart Schaefer
2023-04-30 19:26 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN=4vMouxgQNP=sfrXDhvtUkgLZgkDd6Z3GZX04rHGOhDwihpg@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).