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,))
The Evolution of a Python Programmer
31–40 of 45 posts
Re: The Evolution of a Python Programmer
#32Re: The Evolution of a Python Programmer
#33A 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,))
while 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)
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.
Re: The Evolution of a Python Programmer
#34Apparently, #EXPERT PROGRAMMER wins for efficiency ;)
Not surprising - many Python built-ins are implemented in C. And for any numerical or computational libraries, doing it in C is all but essential. Tangential, but this is why NumPy totally changed my workflow. I can use all of the benefits of Python, including its libraries and syntax, and still have a program that executes at the speed of C, rather than Python[1]. [1] Not literally the speed of C, but you get the id…
Re: The Evolution of a Python Programmer
#35Re: The Evolution of a Python Programmer
#36Here is the discussion from the last time this was posted (90 Comments): http://news.ycombinator.com/item?id=1087068
Re: The Evolution of a Python Programmer
#37Re: The Evolution of a Python Programmer
#38If anyone's interested (I am because I found myself to be a 'Lazier programmer') - Timeit's time for three functions: Lazy Programmer - 0.907521744301 Lazier Programmer - 1.0473810545812512 Using math.factorial - 0.12187403971609001
A 'lazier programmer' who actually checked the optimization of various factorial methods? There's a joke in there somewhere...
Re: The Evolution of a Python Programmer
#39If anyone's interested (I am because I found myself to be a 'Lazier programmer') - Timeit's time for three functions: Lazy Programmer - 0.907521744301 Lazier Programmer - 1.0473810545812512 Using math.factorial - 0.12187403971609001
A 'lazier programmer' who actually checked the optimization of various factorial methods? There's a joke in there somewhere...
Re: The Evolution of a Python Programmer
#40Here is the discussion from the last time this was posted (90 Comments): http://news.ycombinator.com/item?id=1087068
Edit: Just realized you might be pointing this out to help the interested reader, I first assumed you were reprimanding for reposting.