From: Alex Gramiak <agrambot@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: [RFC] Some new vector procedures (vector-{memq, apply, to-string, ...})
Date: Sat, 20 Apr 2019 12:18:01 -0600 [thread overview]
Message-ID: <87bm107d7q.fsf@gmail.com> (raw)
In-Reply-To: <83y344a97a.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 20 Apr 2019 20:16:25 +0300")
Eli Zaretskii <eliz@gnu.org> writes:
> Isn't seq-position the equivalent of vector-index?
It's quite similar (I forgot that it took an optional predicate), though
seq-position takes a 2-arg procedure that's supposed to check for
equality, while vector-index takes a 1-arg procedure. One can implement
one in terms of the other.
> Anyway, if some algorithms are missing from seq.el, maybe we should
> just add them there instead of starting an entirely new family of
> primitives?
Ideally. Though in the case of vector-partition the size of the 2
partition vectors is not known in advance, so a Lisp implementation
would have to create two extra Lisp vectors as opposed to using
SAFE_ALLOCA. That is, unless Elisp grows a growable/resizeable vector
type (which is something I was thinking about -- would that be denied?).
>> > As for speed, did you have any application where the speed of the Lisp
>> > implementation was inadequate?
>>
>> For vector-memq, the Lisp implementations almost disallow it from being
>> used over memq/lists. The equivalent in seq.el, seq-position, is ~100x
>> slower for smaller vectors and ~200x for larger (500 elements) vectors.
>
> The factors don't really answer my question. The question was whether
> some real-life application that uses seq.el is so slow that moving
> them to C is necessary. IOW, the question was about absolute times,
> not relative times. If you can describe such use cases, I'd like to
> discuss them with the participation of seq.el's maintainer first.
Currently the only (M)ELPA package I use that depends on seq is
Flycheck, that doesn't seem to use seq with vectors.
>> The main two I care about here are vector-memq/vector-member.
>
> Please tell why in more detail.
Well, it's a stupid itch, but sometimes I see the (memq elt <list
of constants>) and think that using a vector would be faster/better,
mainly since memq has to check for cycles. More generally, there's
currently no way to check existence in a vector nearly as fast as one
can check existence in a list, which is unusual in programming
languages. This unfairly discourages usage of vectors in appropriate
places.
I don't believe that the vector-memq/member procedures would pose a
maintenance burden like some of the others (vector-apply in particular)
would.
next prev parent reply other threads:[~2019-04-20 18:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-19 20:49 [RFC] Some new vector procedures (vector-{memq, apply, to-string, ...}) Alex Gramiak
2019-04-20 7:04 ` Eli Zaretskii
2019-04-20 16:50 ` Alex Gramiak
2019-04-20 17:16 ` Eli Zaretskii
2019-04-20 18:18 ` Alex Gramiak [this message]
2019-04-20 19:11 ` Eli Zaretskii
2019-04-20 19:54 ` Alan Mackenzie
2019-04-20 20:09 ` Óscar Fuentes
2019-04-20 22:54 ` Paul Eggert
2019-04-21 3:01 ` Using SMALL_LIST_LEN_MAX for memq and list_length (was: [RFC] Some new vector procedures (vector-{memq, apply, to-string, ...})) Alex Gramiak
2019-04-21 1:52 ` [RFC] Some new vector procedures (vector-{memq, apply, to-string, ...}) Alex Gramiak
2019-04-21 5:50 ` Eli Zaretskii
2019-04-21 4:05 ` Stefan Monnier
2019-04-21 20:34 ` Alex Gramiak
2019-04-21 21:01 ` Stefan Monnier
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=87bm107d7q.fsf@gmail.com \
--to=agrambot@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.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.