Re: eql faster than = (integer comparison on sbcl)?
- From: "Tim Bradshaw" <tfb+google@xxxxxxxx>
- Date: 28 Feb 2007 08:43:03 -0800
On Feb 28, 4:20 pm, krewin...@xxxxxxx wrote:
It works fine with sbcl 1.0.1 (on linux i686), but it gets faster if
the :test #'= is replaced by #'eql. Why is that? Shouldn't the #'=
version be faster (since it's a more specific test)?
Any pointer would be appreciated.
If the compiler can make the right assumptions they should be compiled
into the same code. But it's not at all clear to me that it can - it
would have to know an awful lot about MEMBER to be able to do this.
It may well be that by the time the comparison predicate is called by
MEMBER, it knows nothing about the types, and = may then have to do
more work (check things actually are numbers, be prepared to signal an
error) than EQL.
But more to the point, the performance of your code will probably be
dominated by list traversal if N is not a fairly small number. You
need a better way of checking for duplicates. If you *really* care
about performance, I'd suggest:
if N is small allocate an N-element array of some good type (bit array
might be worth trying, else array of some immediate type). Use this
to know when you have dups. (try and allocate it on the stack...)
If N is large use a hashtable.
--tim
.
- Follow-Ups:
- Re: eql faster than = (integer comparison on sbcl)?
- From: krewinkel
- Re: eql faster than = (integer comparison on sbcl)?
- References:
- eql faster than = (integer comparison on sbcl)?
- From: krewinkel
- eql faster than = (integer comparison on sbcl)?
- Prev by Date: Re: eql faster than = (integer comparison on sbcl)?
- Next by Date: Re: A style question
- Previous by thread: Re: eql faster than = (integer comparison on sbcl)?
- Next by thread: Re: eql faster than = (integer comparison on sbcl)?
- Index(es):
Relevant Pages
|