[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] Some new vector procedures (vector-{memq, apply, to-string, ..

From: Alex Gramiak
Subject: Re: [RFC] Some new vector procedures (vector-{memq, apply, to-string, ...})
Date: Sat, 20 Apr 2019 10:50:28 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: Alex Gramiak <address@hidden>
>> Date: Fri, 19 Apr 2019 14:49:39 -0600
>> Here are a few procedures that should make using vectors in Elisp a bit
>> nicer. They are in C since all the Elisp versions I've tried were too
>> slow for such simple procedures.
> Doesn't seq.el already provide this functionality?

Some, but not all. I don't see a vector-partition equivalent
(seq-partition is different), or a vector-index equivalent
(seq-find/cl-find return the element instead of the index, and is ~10x

I don't see any replacement for vector-apply, but I admit that the worth
of that one might not be worth the change at this point.

Though I just remembered that (concat vec) does the same as
vector-to-string; if vector-to-string is added, then I suppose it should
be a Lisp wrapper around concat just like string-to-vector is around

> 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.
A cl-loop implementation is just slightly better than seq-position.

The main two I care about here are vector-memq/vector-member. The other
ones were just ones I thought up while I was at it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]