[Top][All Lists]

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

Re: Making 'eq' == 'eql' in bignum branch

From: Stefan Monnier
Subject: Re: Making 'eq' == 'eql' in bignum branch
Date: Sun, 19 Aug 2018 20:04:35 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Regarding `eq` for bignums, there seems to be some reluctance to
just defining `eq` to be an alias of the current `eql` and I think
I agree because my current approach is more costly now with the new
bignum code: `eql` used to just do

    FLOATP (x) ? costly_eql (x, y) : EQ (x, y)

where FLOATP would just check the 3 low bits of `x`.  But now we have to do

    (FLOATP (x) || BIGNUMP (x)) ? costly_eql (x, y) : EQ (x, y)

where BIGNUMP not only checks the low order bits of `x` but also looks at
the pseudovector_header of `x` if x is a pseudovector (to see if it's
a bignum), so the cost in CPU time is larger and the cost in code size is
even larger yet.

So I think hash-consing bignums makes sense.  It will bring us back the
equivalence between `eq` and `eql` for integers (hence bringing us
closer to making `eq == eql` which I think is a very worthy goal), and
I think its cost should not be too high in practice: the time to lookup
up a GMP number in a hash table basically should never be longer than
the time it took to construct this number in the first place, so that's
a worst-case slowdown factor of 2 which I think is perfectly acceptable.


reply via email to

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