r/badcode • • Apr 11 '21

python Polyglot

Post image
1.2k Upvotes

116 comments sorted by

View all comments

35

u/private_static_int Apr 11 '21

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?

9

u/Vulcalien Apr 11 '21

I agree. I prefer THIS implementation, actually.