realworldocaml / book

V2 of Real World OCaml
https://dev.realworldocaml.org
Other
1.18k stars 175 forks source link

New comment on block [block-idp7712448] #1995

Closed supki closed 11 years ago

supki commented 11 years ago

It's not clear what the second sentence of this paragraph tries to communicate. Where do "long lists" come into play when matching strings? How exactly these matches could be outperformed by hashtables?

bactrian commented 11 years ago

This comment references this from milestone beta1: https://realworldocaml.org/beta1/en/html/lists-and-patterns.html#idp7712448

Context:

Generally, pattern matching is more efficient than the alternatives you might code by hand. One notable exception is matches over strings, which are in fact tested sequentially, and which for long lists can be outperformed by a hashtable. But most of the time, pattern matching is a clear performance win.
yminsky commented 11 years ago

Blech. I meant, matches containing long sequences of string patterns will be slow, because they're tested sequentially. I clarified the language.