Learning real-time programming
A time in which I was very motivated to learn was in a real-time programming class. I had no particular interest in real-time programming (nor did I really know what it was when I enrolled), but I was hooked after the first week in which we were all given an ATMega16 microcontroller, and told that our mark would be based on trying to use this board to do something interesting.
After a few assignments teaching us the basics of programming the microcontroller, we had two months of free reign to work on our projects. While we were allowed to take the boards home, there were many evenings where the majority of the class stayed late working on their projects and sharing in the frustrations of working with this finnicky board, and the triumphs of getting it to do the simplest things.
I remember, in particular, the moment where I got my board to properly output video to a monitor. We had to write our own drivers, so I spent a week poring over the technical specifications of VGA. When I was finally able to produce a test pattern on the screen, it was like scoring the game winning goal in overtime.
In the end, I reproduced Atari Breakout on the little board, and was very pleased with myself. It’s very possible that I also learned something in the process.
Why learn multiprocessing in Python?
I spent a summer working in an experimental neuroscience lab, helping with data analysis while developing a model. It was my first experience working with real world data (not toy data sets) and I was very eager to show the members of this lab that they could get a lot of work done quickly with Python scripts.
I spent about a week writing a script that would analyze a whole directory of large data files and produce a bunch of nice looking plots. After working out the inevitable bugs on a small data file, I set it to analyze everything… and waited three hours for it to finish. Not much faster than just analyzing one file at a time! When I thought about it, I realized that it was analyzing one file at a time; the only thing I’d done is reduce the amount of typing at the shell.
This prompted me to learn multiprocessing in Python. Over the next few days, as analysis jobs were running, I changed that script so that it would run analyze each file in a separate process, making full use of the CPU’s 8 cores. What originally took three hours now ran in about 30 minutes!