unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* cl position performances
@ 2010-02-23  9:30 Thierry Volpiatto
  2010-02-24 18:24 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Volpiatto @ 2010-02-23  9:30 UTC (permalink / raw)
  To: emacs-devel

Hi,
i wrote a very simple definition of `position' for use in
traverselisp.el,(to avoid warnings) and i noticed that this is faster
than the usual cl `position'.
That can be interesting for very large list.

,----
| (defsubst* traverse-position (item seq &key (test 'eq))
|   "A simple replacement of CL `position'."
|   (loop for i in seq for index from 0
|      when (funcall test i item) return index))
`----

,----
| ELISP> (position (bookmark-get-bookmark "mes_scripts") bookmark-alist)
| 525
| ELISP> (traverse-position (bookmark-get-bookmark "mes_scripts") bookmark-alist)
| 525
`----

,----
| position           2           0.000817      0.0004085
| traverse-position  1           0.000283      0.000283
`----

Also,

would be great all the (great) CL package be more integrated in elisp.

Just an example:

Try to get documentation of this same `position' function with C-h S.

-- 
Thierry Volpiatto







^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: cl position performances
  2010-02-23  9:30 cl position performances Thierry Volpiatto
@ 2010-02-24 18:24 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2010-02-24 18:24 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: emacs-devel

> I wrote a very simple definition of `position' for use in
> traverselisp.el,(to avoid warnings) and i noticed that this is faster
> than the usual cl `position'.
> That can be interesting for very large list.

Do you happen to know or have some idea of where the speed difference
comes from?

> Try to get documentation of this same `position' function with C-h S.

Very good point, please post this to bug-gnu-emacs.


        Stefan




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-24 18:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23  9:30 cl position performances Thierry Volpiatto
2010-02-24 18:24 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).