all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Mattias Engdegård" <mattiase@acm.org>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	Ag Ibragimov <agzam.ibragimov@gmail.com>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: Pattern matching on match-string groups #elisp #question
Date: Sun, 28 Feb 2021 10:37:25 -0500	[thread overview]
Message-ID: <jwv7dmsurzz.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <62A88DEE-5BFD-4479-AB15-1A43DC2B299D@acm.org> ("Mattias Engdegård"'s message of "Sun, 28 Feb 2021 14:46:42 +0100")

> 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




      reply	other threads:[~2021-02-28 15:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25  5:11 Pattern matching on match-string groups #elisp #question Ag Ibragimov
2021-02-25 14:55 ` Basil L. Contovounesios
2021-02-25 15:32   ` Stefan Monnier
2021-02-25 18:28     ` Mattias Engdegård
2021-02-26  4:31       ` Stefan Monnier
2021-02-26 10:24         ` Mattias Engdegård
2021-02-26 19:38           ` Stefan Monnier
2021-02-27 10:17             ` Mattias Engdegård
2021-02-27 14:39               ` Stefan Monnier
2021-02-27 18:10                 ` Mattias Engdegård
2021-02-27 20:32                   ` Stefan Monnier
2021-02-28 13:46                     ` Mattias Engdegård
2021-02-28 15:37                       ` Stefan Monnier [this message]

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=jwv7dmsurzz.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=agzam.ibragimov@gmail.com \
    --cc=contovob@tcd.ie \
    --cc=emacs-devel@gnu.org \
    --cc=mattiase@acm.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.