emacs-devel
[Top][All Lists]
Advanced

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

hash-consing bignums and eq==eql


From: Stefan Monnier
Subject: hash-consing bignums and eq==eql
Date: Tue, 28 Aug 2018 10:08:57 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> The whole purpose of hash-consing (for me) is to avoid turning EQ into
> something like:
>
>     if (BIGNUMP (x))
>         return slow_eq (x, y);
>     else
>         return x == y;

BTW, hash-consing bignums would have the following advantages:
- EQ is just as fast as before.
- EQ is equivalent to EQL for all integers.
- While bignum operations would be somewhat slower (30-40% according to
  a message I can't find any more), they'd still be faster than what
  we had before (i.e. which varies between "signals an error" and "uses
  a list of cons cells").

Admittedly, if we used a dedicated tag for bignums, eql could turn into

    BIGNUM_OR_FLOAT_P (x) ? slow_eql (x, y) : (x == y);

where BIGNUM_OR_FLOAT_P can be just as efficient as FLOATP, so it
would be cheap enough (IMO) to make `eq` an alias for `eql`.



        Stefan



reply via email to

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