Live data from Hacker News

The Evolution of a Python Programmer

gist.github.com

31–40 of 45 posts

Re: The Evolution of a Python Programmer

#31

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,))

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)

Re: The Evolution of a Python Programmer

#33

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,))

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)

It 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.

Re: The Evolution of a Python Programmer

#34
post #7

Apparently, #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…

Programs as fast as the speed of light!

Re: The Evolution of a Python Programmer

#38
post #23
post #4

If 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...

Well, he only bothered to check three of them.

Re: The Evolution of a Python Programmer

#39
post #23
post #4

If 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...

a lazy programmer is one who will write a shell script in an hour to generate three lines of boilerplate...

Re: The Evolution of a Python Programmer

#40
post #2

Here is the discussion from the last time this was posted (90 Comments): http://news.ycombinator.com/item?id=1087068

On the other hand, that was 769 days ago.

Edit: Just realized you might be pointing this out to help the interested reader, I first assumed you were reprimanding for reposting.

Post reply on HN