[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pattern matching on match-string groups #elisp #question
From: |
Stefan Monnier |
Subject: |
Re: Pattern matching on match-string groups #elisp #question |
Date: |
Sun, 28 Feb 2021 10:37:25 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> I went with dotted lists (a b c . d) because benchmarking showed it to be
> faster than either proper lists or vectors, the generated code is smaller
> than for lists, and the case of a single variable reduces naturally to no
> consing at all.
Nice.
> Looking a bit closer it gets more nuanced: one reason why
>
> (pcase (list 1 2 3) (`(,a ,b ,c) (+ a b c)))
>
> is faster than
>
> (pcase (vector 1 2 3) (`[,a ,b ,c] (+ a b c)))
>
> is that the latter contains three general function calls: to `vector`,
> `vectorp`, and `eql` (for checking the length), whereas the list version has
> byte-ops for everything.
Very good point. The choice of which primitives deserve their own
bytecode was made many many years ago and it likely deserves
a serious reconsideration [ we still have dedicated byte codes for
Btemp_output_buffer_show and Btemp_output_buffer_setup ;-( ]
Personally, I'd vote to start by making the `eq` byte code return the
value of `Feql` ;-)
Stefan
- Re: Pattern matching on match-string groups #elisp #question, (continued)
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/25
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/25
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/25
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/26
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/26
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/27
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/27
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/27
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/27
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/28
- Re: Pattern matching on match-string groups #elisp #question,
Stefan Monnier <=