emacs-devel
[Top][All Lists]
Advanced

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

Re: seq.el and the complexity of Emacs Lisp.


From: João Távora
Subject: Re: seq.el and the complexity of Emacs Lisp.
Date: Tue, 7 Nov 2023 10:24:36 +0000

On Mon, Nov 6, 2023 at 8:54 AM Gerd Möllmann <gerd.moellmann@gmail.com> wrote:
>
> Richard Stallman <rms@gnu.org> writes:
>
> Can't say much about what you write before this. I wasn't there when
> seq/map, pcase, or other stuff, was added, but...
>
> > Could we replace all the cl-lib sequence function calls with seq-
> > calls, in core and GNU ELPA code?  Seq is simpler and cleaner, so that
> > would be an improvement.  We could keep cl-lib permanently for
> > compatibility for external code, but it would not need to be loaded
> > (into Emacs or your brain) very often.
>
> ...you are losing me here. I'm still wondering what seq/map are good
> for in the first place.

Presumably, it's good for handling custom sequence types, such as lazy
lists.  That's a worthy goal, very worthy even, but this polymorphism comes
at a runtime cost, of course.  And worthy as it may be, there's no use
of that feature in the Emacs tree (as far as I can tell from quick greps),
so it can't really be the "technical reason" for why seq.el is preloaded
and or recommended.

> Considering something "cleaner" is just a
> feeling, isn't it? A feeling I don't share.

Absolutely.  I also think "cleaner" is a very weak argument.

Anyway, I think this discussion could use some data:

(require 'cl-lib)

(defun bench-seq-some (seq)
  (seq-some #'identity seq))

(defun bench-cl-some (seq)
  (cl-some #'identity seq))

(defun bench-cl-loop-list (l)
  ;; checks for some types of improper lists
  (cl-loop for e in l thereis (identity e)))

(defun bench-cl-loop-vec (v)
  (cl-loop for e across v thereis (identity e)))


(when nil
  ;; Small lists
  (let ((l (list nil nil nil nil t)))
    (benchmark-run 1000000 (bench-cl-some l))) ;; (0.179339 0 0.0)

  (let ((l (list nil nil nil nil t)))
    (benchmark-run 1000000 (bench-seq-some l))) ;; (2.726298 19
0.7982190000000031)

  (let ((l (list nil nil nil nil t)))
    (benchmark-run 1000000 (bench-cl-loop-list l))) ;; (0.29131 0 0.0)

  ;; Big lists
  (let ((l (make-list 10000000 nil)))
    (benchmark-run 1 (bench-cl-some l))) ;; (0.142612 0 0.0)

  (let ((l (make-list 10000000 nil)))
    (benchmark-run 1 (bench-seq-some l))) ;; (0.379376 0 0.0)

  (let ((l (make-list 10000000 nil)))
    (benchmark-run 1 (bench-cl-loop-list l))) ;; (0.292876 0 0.0)

  ;; Small vectors
  (let ((v (vector nil nil nil nil t)))
    (benchmark-run 1000000 (bench-cl-some l))) ;; (4.058951 53
1.6585750000000008)

  (let ((v (vector nil nil nil nil t)))
    (benchmark-run 1000000 (bench-seq-some l))) ;; (2.61798 25
0.7980089999999986)

  (let ((v (vector nil nil nil nil t)))
    (benchmark-run 1000000 (bench-cl-loop-vec v))) ;; (0.306206 0 0.0)

  ;; Big vectors
  (let ((v (make-vector 10000000 nil)))
    (benchmark-run 1 (bench-cl-some v))) ;; (1.910587 14
1.2171730000000025) (DREADFUL, EASY TO FIX?)

  (let ((v (make-vector 10000000 nil)))
    (benchmark-run 1 (bench-seq-some v))) ;; (0.33895600000000004 0 0.0)

  (let ((v (make-vector 10000000 nil)))
    (benchmark-run 1 (bench-cl-loop-vec v))) ;; (0.325975 0 0.0)


  )



reply via email to

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