Archive for July, 2009

Puzzling Python

July 24, 2009

Because many programmers I respect are fond of Python, I’m forcing myself to learn it (again). On my previous attempts, I ran into some annoyances and dropped it. This time, I’m trying to solve some Facebook puzzles by gluing together existing libraries. I tried the Peak Traffic puzzle, which is to enumerate the maximal cliques in a directed graph. Some searching led me to an excellent library for graph problems called NetworkX. Some tinkering with the library hit the first problem: on very large complete graphs, I kept blowing the stack. That’s because v0.99 uses (perfectly normal) recursion to solve the problem but hits a stack limit in Python. In v1.0, the devs were forced to implement their own stack to get around this annoying limit. The second issue is that this is a branch & bound optimization problem, which can easily make use of many cores. Instead, the program maxes out at 50% cpu. This would have been trivial to parallelize in .NET 4.0 or Fortress with parallel blocks.

So I thought maybe Jython might solve both problems. Unfortunately, Jython (v2.5) is 4X slower than CPython running the exact same script on a very large input file. Next, Jython also sets the recursion limit to 1000 stack frames, so I ran into the same issue. I know I can raise it manually, but that doesn’t help when I write a program and don’t know how far I’m going to recurse. Why set an arbitrary limit? Just throw the same runtime exception when the platform runs out of space like every other language on the planet. Finally, I imported jsr166, an excellent threadpool library for Java. But on a simple fibonacci test, the performance was so much slower than the equivalent Java program that it simply wasn’t worth considering. It did, however, make use of more threads, though it rarely went over 80%. Maybe there’s a lock somewhere that’s slowing things down. In summary, Jython sucks and CPython is acceptable.

Orbitz is screwing their customers

July 22, 2009

[ed: An Orbitz rep says they don't have the capability to tweak prices in this way. It's probably a mistake, but others have seen this happen too.]

Someone told me a few months ago that Orbitz will detect and raise prices for some customers. It didn’t occur to me to check this until last night. I found a good deal on Orbitz for a hotel+car package, but looked around the web for better deals. After a few minutes, I reran the search on Orbitz and the same deal came up $200 more expensive. I fired up IE’s InPrivate browser and tried again. Now the original, cheaper price showed up. I reran the search in a previous browser and still got the $200 extra charge. Because I lack an MBA, I don’t understand how screwing your frequent customers is a good business tactic. I’ll be searching Orbitz and other travel sites using InPrivate or InFilter mode from now on because I don’t trust their prices anymore. If more people find out about this, people will lose trust in Orbitz and use it less frequently. I suggest people use a different browser or computer to verify that you aren’t getting screwed on prices, particularly package deals.