On 1/1/20 7:45 AM, Stefan Monnier wrote: > We could/should do hash-consing of bignums, tho. It won't affect code > that doesn't use bignums, and should have a fairly minor performance > cost for bignums while making their semantics more clean. I did that, and surprise! it sped up 'make compile-always' by about 7% on the two platforms I tried it on (Fedora 31 and Ubuntu 18.04.3, both x86-64). Although hash-consing of bignums slows down computations that do nothing but generate new bignums (a slowdown of 38% on my microbenchmark) such computations are reasonably rare, and the benefit having 'eq' be more-compatible with traditional Emacs (as well as the abovementioned speedup in more-typical code) seems to make this tradeoff well worthwhile. Code patch against Emacs master attached. Given the performance boost, at least this should go into master; not so sure about emacs-27, though (pro: eq is more compatible; con: it's a last-minute change to emacs-27). Two or three issues: * Should we document that eq == eql on bignums, or continue to leave this stuff unspecified? * Should we try hash-consing floats too? Maybe it wouldn't be as slow as we thought, for typical computations anyway.... * The attached patch could probably be sped up a bit by supporting sets as well as mappings at the low level, since bignum_map is really just a set of bignums. Not sure it's worth the effort, though.