scheinerman / Permutations.jl

Permutations class for Julia.
Other
51 stars 14 forks source link

Improve performance of `cycles` and `sign` #19

Closed dkarrasch closed 3 years ago

dkarrasch commented 3 years ago

I came across this package in search of a quick sign implementation. I noticed a few optimization possibilities in cycles. Moreover, I found the sign implementation very inefficient, because all you care about is the length of the result of cycles(p), so one can take the same code and replace every array concatenation by a += 1. That reduces memory allocation and yields significant performance improvements.

scheinerman commented 3 years ago

Thanks @dkarrasch . I've merged your changes and will release as a new version.