Five things I hate about Python

January 29th, 2008, 10:15 pm PST by Greg

A while ago, I stumbled on somebody else’s blog entry Five things I hate about Python. The game (apparently) is to pick your favourite programming language and pick five things you don’t like about it.

This seems most common among the Python crowd: Python 2, Python 3, Python 4. It’s probably because everybody loves Python. But, I did manage to find a few others: C,
Vista, Linux.

So, here are my five things:

  1. No parallelism. The Python interpreter has a global lock that makes it impossible to parallelize execution. My processor has two cores, multiple pipelines, and a vector unit. Wouldn’t it be spiffy to use those? I have used the Parallel Python module to get around this (by spawning multiple interpreters), but it’s a hassle, and only applicable in certain cases.

    To be fair, this is a common problem in imperative languages, which force the programmer to precisely specify how thing are calculated. It’s much easier for a compiler to parallelize things in functional language, which have the programmer specify only what is calculated. Maybe Haskell is the answer to all of our problems? Hey… why are all the 383 students looking at me like that?

  2. Late Binding. This is the mechanism that allows the beauty of duck typing, so it’s probably a net win. It comes up in situations like this:

    def add(a,b): return a+b

    Until the function is called, there’s no way for Python to know whether the + there is addition, string concatenation, or something else. So, when each statement executes, Python has to decide what operators (or whatever) to use at that moment. The net result is slowing the language down a lot.

    Apparently PyPy has some improvement here, and Pyrex allows extension modules with early binding.

  3. Type confusion. I don’t know if it’s the duck typing or weak typing, but beginning programmers (aka CMPT 120 students) often have problems getting the type that a particular value has. I very often see students converting a type to itself. For example:

    name = str(raw_input("Name: "))
    count = int(0)

    That indicates some serious confusion about what’s going on. Or maybe I’m a bad teacher. I’d accept that as an explanation.

  4. GUI libraries. The standard Python install comes with only a Tk binding for GUI development.

    I really wish wxPython came with the default install. Then, we could all use it and assume it would be there. It would make Python a pretty serious contender for cross-platform GUI development.

  5. Standard library. One of the principles of Python is that “the batteries are included”. In other words, the libraries you need are there by default.

    That’s usually true, but there are a few things I wish were always there. The Python modules that I seem to have to install the most often are: Biggles, Imaging, Numarray/Numeric, Parallel Python, PyGame.

    As an aside, maybe if the Imaging and PyGame modules were accepted into the standard library, there would be some pressure to get some good documentation going for them.

Snowy Night

January 28th, 2008, 12:45 pm PST by Greg

It snowed in Burnaby yesterday (but somehow not most of the rest of the lower-mainland). After the last snowfall, I had looked out of the window at night and thought that the snow under the streetlights looked cool. Unfortunately, I didn’t have the presence of mind to do anything about it.

So last night, I grabbed my camera and panoramic tripod head and set out.

I walked north a few blocks to get away from Hastings (figuring that farther from Hastings would mean less traffic). My first stop was smack in the middle of a street for a full 360° panoramic shot:

street panorama

[You can click the link there for larger versions. If you have a Java plugin working, you can click the “View Panorama” link on the left of that page for a nice drag-around viewer.]

Making a panorama like this requires 40–50 separate frames (with the lens I have) that are then stitched together. Everything has to be set to manual on the camera (exposure, focus, white balance). The whole process takes 10–15 minutes for a single “picture”.

In this case, each frame was exposed for 1 second at f/5.6, ISO 1600. I left the white balance set for for tungsten light. That’s why the image has the orange colouring from the sodium streetlights. I only had to move our of the way of a car once during that shot.

Having had enough of dodging traffic, I found myself a convenient traffic circle for the next one:

traffic circle panorama

The camera settings were the same, except this time I set a custom white balance so the snow is actually white. That is exactly what I was hoping for when I set out.

On the way back, I saw some drops of water that had frozen on a little tree, and couldn’t resist stopping for one last shot of them. I set the aperture to f/2.8 for that shot for maximum Bokeh goodness.

Finally, with frozen fingers, I went home and fired up Hugin to get the panoramas together.

Edit 22:00: Shrunk the panoramas in the gallery. The Java VM seems to have a memory limit that wouldn’t let the originals display.

On Teaching

January 25th, 2008, 12:33 pm PST by Greg

Well, it’s Link Friday again. I thought I had a lot of links to share, but I don’t have nearly as many links backed up as straight-up blog topics. Maybe Link Friday won’t be every Friday.

Anyway, for this week I have some links related to teaching. I teach stuff to people all the time, and suppose I must know something about it. Believe it or not, there are people that have made observations that even I haven’t had.

First are a couple of things my students should read. Everybody below about 85% in CMPT 120 should read How NOT to go about a programming assignment (Google cache link). Part of teaching a first year programming course is seeing each and every one of these things. Repeatedly.

This prof’s Top Ten No Sympathy Lines are really interesting. In particular, his answer to “There Was Too Much Memorization” was really insightful.

For the last several years, I have been trying to minimize the textbooks required for my classes: the pricing is criminal and they usually aren’t all that good. My rule has been to only require texts if they are really good and if I’m going use them very heavily. Otherwise, they are only recommended. So, this guy is my hero: UVSC prof. quits books.

I’m not sure that Taylor Mali on what teachers make particularly applies to me, but it makes me think that the high school teachers I know are a lot cooler.

Finally, the… um… darker side of teaching. Apparently, according to a peer-reviewed article, Teaching may be hazardous to your marriage. And the complementary article: If College-Themed Porn Were Real.

Buying vs Renting

January 23rd, 2008, 5:23 pm PST by Greg

A while ago, I posted a calculation that I had done on renting a home vs buying one. Those calculations have been intriguing me ever since. I have had several conversations with people about the pros and cons, and and what-if scenarios.

I finally decided that I needed to automate these calculations so I could easily handle the what-ifs. Thus came to be my very own Renting vs Buying Calculator.

Follow that link, have a look, and play with some numbers. The buttons beside text boxes generally calculate/estimate the corresponding value from relevant numbers above. You only really have to fill in the numbers without buttons beside them. The defaults are my current best-guess at the economics of buying/renting a nice condo in suburban Vancouver.

It’s shocking how hard it is to make buying financially better, as long as you assume two important things:

  • House values aren’t going to continue to rise at the outrageous rates they have for the last five years in North America. This is already slowing, and betting your only/largest investment on that assumption is foolish.
  • You have the discipline to invest in something else (mutual funds or what have you) without the pressure of a looming mortgage payment. Automatic monthly withdrawals make this easy, but it has to actually happen.

The only scenario that I can find where buying has a marginal benefit is buying a small detached home (one of the 1970s-era Vancouver specials), and renting a basement suite. Of course, that comes with the extra responsibilities and headaches of being a landlord.

On the other hand, it can be hard to find rental places that are as nice as what you might imagine buying. The rental market seems to generally target “livable”, not “nice”.

Any comments on the calculator are appreciated. It has everything I can think of that should be in there, but some of you might know better than me.

Update 12/2010: vancouvercondo.info has created a similar calculator.

Icy brick. Kat slips. Damn UNC!

January 22nd, 2008, 5:16 pm PST by Kat

I like this 6-word thing. If you don’t want to read this post, you get the jist of it from the 6-word title. Maybe this will be my blog schtick.

It was cold last night, and apparently because yesterday was a holiday, nobody at UNC thought about salting the brick walkways. I, along with other people, was sliding around trying to get to work this morning. My foot slipped behind me and I went down onto my knee. The good things are that I managed to stay upright and that nobody was around to see me being less than graceful. The bad thing, my knee kinda hurt for most of the day and now I have a big bruise.

Damn you UNC for not salting!!!!

See Greg, I told you I needed those Lee Valley spiky shoe things!

27 Dresses

January 21st, 2008, 1:38 pm PST by Greg

As most of you know, Amanda is leaving Computing Science and movin’ on up to Student Services. That’s very sad, and I’ll blog about it later.

Because Amanda’s a good boss, she wanted to do something for her team before she left. She decided on playing hookie on Friday afternoon and taking the team to a movie. (But shhhhh! It’s a secret: no sane manager would play hookie with their entire team.)

We discussed the movie a bit before we went. I was campaigning for Juno. Instead, she chose 27 Dresses.

Now, I’m not above watching a decent chick-flick. I remember About a Boy being okay, for example. Actually, I kind of like Hugh Grant. This movie, on the other hand, wasn’t “decent”. Not even close.

None of the characters were sympathetic: I hated them all. Even the protagonist (who I suspect I was supposed to care about) was whiney, meek, and generally annoying. The “pretty” sister wasn’t actually as pretty as the not-as-pretty, practical one. Both guys were dicks and too stupid to live.

Basically, if the movie had ended with everyone dying in a fire, I would have been fine with that. The only exception was Judy Greer, who I think I have a bit of a crush on, and whose character was actually compelling (but on screen for maybe two minutes).

So guys: if you have a choice between seeing 27 Dresses and paying nine bucks to sit in the theatre lobby and play video games, get yourself a roll of quarters. The women in the crowd seemed to like it, though.

My day in 6 words

January 21st, 2008, 1:22 pm PST by Kat

So Greg told me about a WIRED article where they asked famous people to write a 6-word story. Well, I’m not famous, but here’s how I spent my Martin Luther King Day in 6 words:

Watched birds sit.  All day.  $*#&%^!

I’m still alive, but the cars around me might not be

January 20th, 2008, 5:05 pm PST by Kat

This joint blog seems to have turned into Greg’s blog lately. So since Greg has decided to blog at least 3 times a week, I’ve decided to try to blog at least once a week. Let’s see how long I can keep it up.

So this has been a bad car week.

Last weekend Lisa’s car started to die. It would not start, and then when it did start, it would stop as she was driving it. Her dad thinks it’s the alternator not staying in place, and so the car thinks she’s taken the key out when she’s driving. Not good!

She called Brian to pick her up, and he had a flat tire. So, she ended up driving it home, but is going to get it checked.

Then today, I went to our aviary to check on the birds. It had snowed yesterday (a dusting, really) and had gotten really cold out, so I wanted to make sure the birds were okay for food and water. As most of you know, I’ve named my car Rusty. He’s EXTREMELY rusty to the point of having my back right shock rusted-stuck. Well, today I think the back left shock joined its right friend. Every time I hit a small pothole or bump in the road with the left side of my car, the entire back end felt like it was… well… not right. I’m hoping something was just frozen because of the cold, but I think that’s probably wishful thinking. I guess it was too much to ask for Rusty to last the final 5 months of my stay here.

So now two of the three cars around seem to be out of commission. 🙁

UPDATE: Monday, January 21

My car is fine. Maybe I was crazy… maybe there was actually something like a piece of ice wedged in my left back shock… who knows. But now my car is perfectly fine. Well… as fine as a crappy car can be! YAY!

Flash Games

January 19th, 2008, 12:08 am PST by Greg

In my thrice-weekly-blogging quest, I’m going to try to use Fridays as “link day”. For the first Greg The Aggregator day, I’m going to link to some of my favourite flash-based games.

Of course, there’s the stupidly-simple Line Rider. The deal is simple: draw lines and a little guy on a sled rides down them. You wouldn’t think that would be so addictive, but I distinctly remember spending an entire Friday afternoon in the CSSS common room with Jen trying to make him do loops, flips, etc.

I have recently been addicted to Filler, which doesn’t seem to be working for me right at the moment, but will likely be back soon. There are some little balls bouncing around: avoid those. You place bigger circles around the grid until you’ve filled up 2/3 of the board.

Shuffle isn’t much more than a flash version of marbles, but fun.

Finally, Zwingo is another marble-like game. Your job is to guard the big marble in the centre with the marble-on-an-elastic that you control.

Okay, none of those sound like much fun, but go play them and find out. Oddly, all of the games I’ve listed here have at least a little physics involved. I guess we’ve figured out what I like in a simple flash game.

To: Curtis

January 16th, 2008, 12:08 pm PST by Greg

Subject: Re: Project Don’t Die Before I Reach The Age Of 28

As one of the facultative vegetarians that you were probably referring to, I feel like I should respond.

My first thought to the taste-of-vegetables problem is fairly straightforward, I think. If you like the taste of meat, do the same thing you would when trying to give a dog a pill: mix it with meat. The obvious device for this is probably the stir fry.

Also, consider the wonders of cheese. Nothing makes broccoli palatable like a cheese sauce. Might I also dare to suggest you have a look at a cookbook or two? They’re like algorithms textbooks, but for food.

One of the things that really pisses me off are people I refer to as “penance vegetarians”. These are the people that seem to treat vegetarianism like it’s punishment for something and have been doing it for far too long. They are the ones that like tofu and snack from little bags of what appears to be bird food. They rave about the food at the Nam.

Vegetarian food can have fat in it. It can even have flavour if you play your cards right.

On the subject of gastrointestinal stress: I’m sure you’ll be fine. The system seems to get used to whatever one has been giving it. For example, I don’t think Mexican people are in a constant state of distress, but Mexican food it’s always an easy way to a punchline for American sitcom characters. Stay the course, and you’ll be fine.

« Previous Entries