Hacker News new | past | comments | ask | show | jobs | submit login
GvR's Blog (neopythonic.blogspot.com)
33 points by kirubakaran on Oct 23, 2008 | hide | past | favorite | 13 comments



Someone jokingly asked me how I would sort a million 32-bit integers in 2 megabytes of RAM, using Python [...] obviously this is a joke question -- the data alone would take up 4 megabytes, assuming binary encoding

This question seems to come up a lot at Google - didn't their CEO ask it of Obama and McCain when they visited?

I like that instead of going into a complicated solution to a tricky problem, GvR shows the very simple and general way to solve a slightly easier version more people are likely to encounter. Unfortunately I was sort of hoping he would take the Programming Pearls approach instead of treating it as a joke. Bently showed several ways to do this kind of constrained memory sorting given differing assumptions, but perhaps that kind of thing just isn't interesting for the places Python is used.


I wrote this algorithm to solve a problem for myself one night about 10 years ago (agree - not a very tough problem, but very useful if you don't have enough memory). I told a client about it and he tried to patent it! I never checked to see if it went through...


You didn't need to; unix sort has been able to do this for way more than 10 years =).


Well, it was a complicated data format for many 10s of GB of seismic data on machines that probably had 32MB or 64MB of memory. The partial sort and merge did the trick for me.


So, what did ya'll think of Anathem?


Stephenson came to do a reading in Cambridge, MA a few weeks ago, of a couple amusing conversations. I haven't read the rest of it yet, but he writes fantastic dialog.


I felt like it was three related but different stories put together. Each 3rd of the book, seemed to have a very unique feel from the others.


I've just started reading it. The first little bit has been rather slow; I'm hoping it picks up considerably.


It was a mind bending exercise.


It's not a terribly hard exercise, I'd expect that almost any programmer could do the math and figure out that a solution requires files. After that I'd expect a candidate to at least sketch out a logical solution.

It's cool that it's Guido, though. And that it's a complete solution.


The point here is to show off (among other things) the buffered I/O in Py3k. It's much easier (i.e. shorter, more readable) in Py3k to implement an efficient solution than in earlier Python versions. If it were a really hard problem, it would be harder to see the benefits of the new language features.



[deleted]


Guido van Rossum. Guy who invented Python.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: