all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rusi <rustompmody@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: return first element in list with certain property
Date: Wed, 22 Nov 2017 06:52:20 -0800 (PST)	[thread overview]
Message-ID: <e1e3532f-b59f-42ff-819d-ff81de697c96@googlegroups.com> (raw)
In-Reply-To: <20171121225216.17011915608ecbb6021c9bc2@speakeasy.net>

On Wednesday, November 22, 2017 at 9:22:18 AM UTC+5:30, James K. Lowden wrote:
> On Tue, 21 Nov 2017 19:37:01 +0100
> Michael Heerdegen wrote:
> 
> > Philipp Stephani  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.  

I dont think its quite as simple as that…

Consider python wherein
- C is typically 2 orders of magnitude (hundreds of times) faster than python
- the two can cohabit quite closely; eg moving a ordinary python loop to a 
vector numpy operation implicitly moves python to C with corresponding speedup
(and speed-down due to conversion etc)

And so the two versions are not just comparing loop vs loop-loop
but loop₁ vs loop₂ - loop₃
where the ₁₂₃ can vary across {interpreter, bare-metal}
we could have all manner of possibilities of speedup and speed-down

Sure its not nearly as simple to add C to elisp as to python
However it is essentially the same thing: elisp and python are interpreters
sitting on top of C. Which in big-O terms means 1 loop vs 2 constant multiplier
vs bare-metal vs interpretive overhead multiplier


  parent reply	other threads:[~2017-11-22 14:52 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-19 20:43 return first element in list with certain property Emanuel Berg
2017-11-19 20:51 ` Eric Abrahamsen
2017-11-19 21:37 ` Philipp Stephani
2017-11-19 22:55   ` Emanuel Berg
2017-11-20 18:51     ` John Mastro
2017-11-20 19:21       ` Michael Heerdegen
2017-11-20 21:20         ` Emanuel Berg
2017-11-20 21:40           ` John Mastro
2017-11-20 22:19           ` Michael Heerdegen
2017-11-20 20:52       ` Emanuel Berg
2017-11-20 20:12   ` Drew Adams
2017-11-20 20:49     ` Eric Abrahamsen
2017-11-20 21:16       ` Emanuel Berg
2017-11-20 22:02         ` Eric Abrahamsen
2017-11-21  1:54           ` Emanuel Berg
2017-11-21  2:18             ` Emanuel Berg
2017-11-21 17:34               ` Michael Heerdegen
2017-11-21 20:10                 ` Emanuel Berg
2017-11-21 21:33                   ` Michael Heerdegen
2017-11-22 21:30                     ` Nicolas Petton
2017-11-22 21:31                   ` Nicolas Petton
2017-11-21 18:01             ` Philipp Stephani
2017-11-21 18:37               ` Michael Heerdegen
2017-11-21 19:26               ` Drew Adams
2017-11-21 20:17                 ` Emanuel Berg
2017-11-21 20:47                   ` Drew Adams
2017-11-21 20:14               ` Emanuel Berg
     [not found]               ` <mailman.4260.1511289435.27995.help-gnu-emacs@gnu.org>
2017-11-22  3:52                 ` James K. Lowden
2017-11-22  5:04                   ` Michael Heerdegen
2017-11-22 14:06                   ` Emanuel Berg
2017-11-22 14:52                   ` Rusi [this message]
2017-11-22 21:28             ` Nicolas Petton
2017-11-23  0:56               ` Emanuel Berg
2017-11-23  1:17                 ` Michael Heerdegen
2017-11-23  1:30                   ` Emanuel Berg
2017-11-25  2:57                 ` John Mastro
2017-11-25  3:54                   ` Robert Thorpe
2017-11-25  4:44                     ` Alexis
2017-11-25  7:10                     ` tomas
2017-11-25 17:11                       ` Emanuel Berg
2017-11-25  7:46                     ` Eli Zaretskii
2017-11-25  8:03                       ` tomas
2017-11-25 19:00                     ` John Mastro
2017-11-25 19:45                       ` Emanuel Berg
2017-11-27  3:44                         ` Michael Heerdegen
2017-11-20 22:59         ` Drew Adams
2017-11-21  1:50           ` Emanuel Berg
     [not found] ` <mailman.4093.1511127491.27995.help-gnu-emacs@gnu.org>
2018-03-06  0:31   ` Robert L.
2018-03-06  8:53     ` Emanuel Berg
2018-03-06  9:29       ` Emanuel Berg
     [not found] <mailman.4086.1511124258.27995.help-gnu-emacs@gnu.org>
2017-11-19 21:19 ` Marco Wahl
2017-11-19 22:51   ` Emanuel Berg
2017-11-21  4:00   ` Emanuel Berg
2017-11-19 21:20 ` Marco Wahl

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=e1e3532f-b59f-42ff-819d-ff81de697c96@googlegroups.com \
    --to=rustompmody@gmail.com \
    --cc=help-gnu-emacs@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.