Cool. Glad you got it working.

That multiply-rotate hash in my last post does yield a noticeable boost. I get 
Python-3.8.2 times of 1.255..1.337, Nim-1.3.3 with default hash times of 
0.391..0.531, and Nim-1.3.3 with that multiply-rotate of 0.205..0.347. So, with 
a fast, good enough hash Nim is over 6x faster than Python here (1.255/.205 = 
6.12x).

Using a faster hash yielding 0.391/0.205 = 1.9x speed-up just Nim-to-Nim is 
unusual, though not shocking. Usually, more work per-lookup is happening that 
masks the cost of the hash function calculation. The new default `hash` is 
"safer" against many hostile situations, such as this one you stumbled upon in 
your first post. One pays a little for that safety/generality, but with Nim 
it's easy to claw back that performance whenever it matters. Just 3 lines of 
code in this case.

Reply via email to