3 ms·
A true hackerish version perhaps: bc = [124, 0, 0, 114, 37, 0, 116, 0, 0, 124, 0, 0, 106, 2, 0, 100, 1, 0, 131, 1, 0, 124, 1, 0, 106, 1, 0, 124,
by lclarkmichalek 15y ago
A true hackerish version perhaps:
bc = [124, 0, 0, 114, 37, 0, 116, 0, 0, 124, 0, 0, 106, 2, 0, 100, 1, 0, 131, 1,
0, 124, 1, 0, 106, 1, 0, 124, 0, 0, 131, 1, 0, 131, 2, 0, 83, 124, 1, 0,
83]
fact = type(lambda:0)(type((lambda:0).func_code)(2, 2, 7, 0,
''.join(map(chr, bc)), (None, 1), ('fact', '__mul__', '__sub__'),
('x', 'acc'), "n/a", "fact", 0, ""),
globals(), "fact", (1,))
- codesuela 15y agowhile I know this is a joke I would argue that this is in no way hackerish, this is an asshole version. Basically a middle finger to anyone who wants to work with your code. Also anything but pythonic. (please note this not meant to be an insult to the parent commenter)
- lclarkmichalek 15y agoIt is hackerish to the extent it demonstrates a knowledge of python's internals, however maybe it would better be described as being written by a former assembly programmer. Also, you might be interested in the fact that Paul Graham argues that his dream language would have inline bytecode. It probably wouldn't be written as a list of integers though. As for this not being pythonic, at least its not self modifying or anything fun. I did once see a talk on obsfucated python that used decorators to implement a Turing complete language, so this is hardly the worst abuse of python ever.