skgrange / threadr

Tools to Thread Pieces Of Data Analysis Together
GNU General Public License v3.0
31 stars 7 forks source link

A faster twos_complement() implementation #4

Closed asilha closed 4 years ago

asilha commented 4 years ago

This version is natively vectorized; thus, it does not need a helper function. It also avoids unnecessary, repeated evaluations of the constant values that result from bitwShiftL, which were replaced by powers of two. As a result, execution becomes roughly a hundred times faster than the original version. Finally, we use the ternary conditional for increased readability. :)