I want to know what Dispatch actually does to rule the list. Why is it so fast?
The documentation says
Dispatch generates a dispatch table which uses hash codes to specify which sets of rules need actually be scanned for a particular input expression.
What is a hash table? How does it specify which sets of rules need actually be scanned for a particular input expression?
What about DeleteCases? Since it is fast too, Does it use hash table too?
DeleteCasesalso use hash table? Because it is fast too. – matheorem Nov 22 '13 at 13:14DeleteCasesis an alternative pattern (Alternatives[elems]), and whenelemsdo not contain patterns, since V8DeleteCaseshas been optimized to work really fast, even for the large number ofelems. I strongly suspect that a hash table was used internally in this case. And this may well be what the OP means here, since I do recall some comments by the OP related to this particular issue. – Leonid Shifrin Nov 22 '13 at 15:18Alternatives? I thoughtDeleteCasesby itself was just a tree traversal? – rm -rf Nov 22 '13 at 15:22Alternatives. Since this change has been made specifically forDeleteCases, it is de facto an improvement forDeleteCases. – Leonid Shifrin Nov 22 '13 at 15:24DeleteCasesuses a hash table.Caseslikewise. – Daniel Lichtblau Nov 22 '13 at 19:17