Data.List.inits is extremely slow
As discussed on libraries@haskell.org, Data.List.inits
is extremely slow (try running print $ length $ inits [1..100000]
if you don't believe me). As discussed, there are at least two reasonable fixes. One of them (named initsR
in the attached) is a one-liner and gives very good performance in general, but poor performance in certain cases that may or may not appear in real code. The other (named initsQ
in the attached) is slightly more complex and slightly slower in general, but its performance appears to be robust. I would personally lean toward initsQ
for Data.List
.
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | ekmett, hvr |
Operating system | |
Architecture |