[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: return first element in list with certain property
From: |
James K. Lowden |
Subject: |
Re: return first element in list with certain property |
Date: |
Tue, 21 Nov 2017 22:52:16 -0500 |
On Tue, 21 Nov 2017 19:37:01 +0100
Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > Please consider Knuth's statement about premature optimization.
> > Until your users have actually complained about the speed of your
> > product and you have benchmarked it and isolated cl-find-if as the
> > culprit, there's no need to micro-optimize. Presumably cl-find-if
> > has performed two iterations for years or decades without anybody
> > being bothered enough to improve it.
>
> Not only that. Seems the second iteration is at least ~50 times
> faster than the first one (using `elt' that is much faster than a
> loop), so it doesn't matter anyway. If your program is slow, the
> second iteration will never be the culprit.
Not only that. ;-) Traversing the list twice is still O(n).
I would guess in elisp the typical list is on the order of a dozen
elements. As Rob Pike says,"Fancy algorithms are slow for small N, and
N is almost always small."
No matter how long the list is, it traversing it twice will only take
at most twice as long. If your design fails when your data size
doubles, you have problems emacs won't solve.
--jkl
- Re: return first element in list with certain property, (continued)
- Re: return first element in list with certain property, Nicolas Petton, 2017/11/22
- Re: return first element in list with certain property, Philipp Stephani, 2017/11/21
- Re: return first element in list with certain property, Michael Heerdegen, 2017/11/21
- RE: return first element in list with certain property, Drew Adams, 2017/11/21
- Re: return first element in list with certain property, Emanuel Berg, 2017/11/21
- RE: return first element in list with certain property, Drew Adams, 2017/11/21
- Re: return first element in list with certain property, Emanuel Berg, 2017/11/21
- Message not available
- Re: return first element in list with certain property,
James K. Lowden <=
- Re: return first element in list with certain property, Michael Heerdegen, 2017/11/22
- Re: return first element in list with certain property, Emanuel Berg, 2017/11/22
- Re: return first element in list with certain property, Rusi, 2017/11/22
- Re: return first element in list with certain property, Nicolas Petton, 2017/11/22
- Re: return first element in list with certain property, Emanuel Berg, 2017/11/22
- Re: return first element in list with certain property, Michael Heerdegen, 2017/11/22
- Re: return first element in list with certain property, Emanuel Berg, 2017/11/22
- Re: return first element in list with certain property, John Mastro, 2017/11/24
- Re: return first element in list with certain property, Robert Thorpe, 2017/11/24
- Re: return first element in list with certain property, Alexis, 2017/11/24