[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is Elisp really that slow?
From: |
Stefan Monnier |
Subject: |
Re: Is Elisp really that slow? |
Date: |
Mon, 13 May 2019 08:37:29 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> can this be sped up?
>
> (while (re-search-forward from nil t)
> (replace-match to t))
That's a perfect example where no matter how many man-years you invest
into a super-duper fancy compiler for Elisp, the above code will not be
affected one bit, because all the time is normally spent within
`re-search-forward` and `replace-match` which are already implemented
in C.
As for whether it can be sped up: yes, no doubt it can. But how to
speed it up will depend on `from`, on the density of matches in the
text, and on the current major-mode, mostly (the complexity of `from`
impacts the amount of time spent in re-search-forward and which
approaches can reduce it, while the major-mode impacts the overhead of
modifying the buffer (via before/after-change-functions)).
I'd expect that in most cases, there won't be many matches so most of
the time is spent in re-search-forward. This is already pretty fast in
the case where the pattern is simple, but if the pattern is complex, our
regexp-engine can be somewhere between not very efficient and
pathologically slow. Fixing this would be great (even better if we can
do it by re-using an existing regexp implementation), especially if we
can do it without slowing down the simple case too much.
Stefan
- Re: Is Elisp really that slow?, (continued)
- Re: Is Elisp really that slow?, Óscar Fuentes, 2019/05/12
- Re: Is Elisp really that slow?, Eli Zaretskii, 2019/05/12
- Re: Is Elisp really that slow?, Óscar Fuentes, 2019/05/12
- Re: Is Elisp really that slow?, Eli Zaretskii, 2019/05/12
- Re: Is Elisp really that slow?, Emanuel Berg, 2019/05/12
- Re: Is Elisp really that slow?, Stefan Monnier, 2019/05/12
- Re: Is Elisp really that slow?, Óscar Fuentes, 2019/05/12
- Re: Is Elisp really that slow?, Stefan Monnier, 2019/05/14
- Re: Is Elisp really that slow?, Óscar Fuentes, 2019/05/14
- Re: Is Elisp really that slow?, Samuel Wales, 2019/05/12
- Re: Is Elisp really that slow?,
Stefan Monnier <=
- Re: Is Elisp really that slow?, Emanuel Berg, 2019/05/13
- Re: Is Elisp really that slow?, Emanuel Berg, 2019/05/13
- Re: Is Elisp really that slow?, tomas, 2019/05/14
- Re: Is Elisp really that slow?, Emanuel Berg, 2019/05/14
- Re: Is Elisp really that slow?, tomas, 2019/05/14
- Re: Is Elisp really that slow?, Emanuel Berg, 2019/05/15
- Re: Is Elisp really that slow?, tomas, 2019/05/15
- Re: Is Elisp really that slow?, Emanuel Berg, 2019/05/15
- Re: Is Elisp really that slow?, tomas, 2019/05/16
- Re: Is Elisp really that slow?, Noam Postavsky, 2019/05/16