I want to define
isGood[___] = False; isGood[#] = True & /@ list
list is a list of several million integers. What's the fastest way of doing this?
On my computer, this takes less then 3 seconds for a million integers if
Retrieval of the results is also quite quick, and is almost independent whether
Out of curiosity, I compared this to the undocumented
We see that both storage and retrieval are a bit faster.
Are you sure you want to use
This seems to be faster to define downvalues
My solution is ugly, but task-specific. It builds a bitmap out of machine-sized integers in imperative fashion and uses Compile. This works reasonably in memory usage for ranges that have at least couple percent of True values.
A million integers:
Originally I wanted to solve this problem using bitwise operations of arbitrarily large integers, but the issue with that is that functional programming with bigints has large return value overheads - even when just some individual bits are twiddled.