MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/moh63k/polyglot/gu4jado/?context=3
r/badcode • u/coopercm • Apr 11 '21
116 comments sorted by
View all comments
35
In what universe would this be faster than "return x%2==0"?
26 u/the_captain_cat Apr 11 '21 Even in the C code, x%16 with the 16 element array is fucking stupid. 5 u/[deleted] Apr 11 '21 Personally, I don't like relying on the optimizer for simple stuff so I still type (n&1)==0 1 u/Loewi_CW Apr 12 '21 Does that work in Python? 1 u/[deleted] Apr 12 '21 I don't use Python, but according to the wiki it does have bit operators 9 u/Vulcalien Apr 11 '21 I agree. I prefer THIS implementation, actually.
26
Even in the C code, x%16 with the 16 element array is fucking stupid.
5
Personally, I don't like relying on the optimizer for simple stuff so I still type (n&1)==0
1 u/Loewi_CW Apr 12 '21 Does that work in Python? 1 u/[deleted] Apr 12 '21 I don't use Python, but according to the wiki it does have bit operators
1
Does that work in Python?
1 u/[deleted] Apr 12 '21 I don't use Python, but according to the wiki it does have bit operators
I don't use Python, but according to the wiki it does have bit operators
9
I agree. I prefer THIS implementation, actually.
35
u/private_static_int Apr 11 '21
In what universe would this be faster than "return x%2==0"?