Speeding up Floyd-Steinberg dithering: an optimization exercise (pythonspeed.com) 2 points by itamarst 2y ago ↗ HN
[–] cprogrammer1994 2y ago ↗ Hi I shaved off 40% more just by replacing multiplication with bitwise operations and ported the code to a standard Python C Extension to avoid relying on JIT.https://github.com/szabolcsdombi/optimized-floyd-steinberg-d...X * 7 is equal to (X << 3) - XX * 3 is equal to (X << 1) + XX * 5 is equal to (X << 2) + X
1 comment
[ 3.4 ms ] story [ 162 ms ] threadhttps://github.com/szabolcsdombi/optimized-floyd-steinberg-d...
X * 7 is equal to (X << 3) - X
X * 3 is equal to (X << 1) + X
X * 5 is equal to (X << 2) + X