alan little’s weblog archive for july 2005

one-word book reviews

26th July 2005 permanent link

Harry Potter and the Half-Blood Prince: perfunctory

Shantaram: revelatory

More on the latter, later.


22nd July 2005 permanent link

I needed something for a project I’m working on that would let me easily enter romanised Sanskrit text on a normal keyboard (or better still, find romanised Sanskrit text on the internet) and then convert it to proper devanagari Sanskrit text in unicode.

Since I’m acutely aware that, as Phillip Eby puts it: “Python as a community is plagued by massive amounts of wheel-reinvention. The infamous web framework proliferation problem is just the most egregious example”, I did a bit of searching first to see if somebody has already done something similar that I could use/adapt/contribute to. It appears not: I found lots of people telling me how “transliterating” code line-for-line from other programming languages into python produces programs that are un-pythonic, ugly and slow – so don’t do it, folks – but nothing that looked anything like what I wanted.

So I wrote Version 0.1 is available here for download in case any body else needs something similar. It even has documentation of sorts.

From a command line it works like this:

python text inputFormat outputFormat > outputFile

… assuming you have python installed. Mac and Linux users do. Windows users can get it here. text can be either the actual text you want transliterated, or the name of a file containing it. inputFormat and outputFormat are what you want to transliterate from and to, e.g. “HarvardKyoto”, “Devanagari”. If you don’t specify an output file, the transliterated results will just be shown on the screen.

See the documentation for examples of how to call transliterator from another python program, which allows you to set up your own transliterations and have more control over input and output encodings.

Version 0.1 supports transliteration to and from Sanskrit Devanagari using IAST, ITRANS and Harvard-Kyoto transliterations. Here’s an at-a-glance table of common Sanskrit transliterations. I think it wouldn't be too big a job to adapt it to modern Indian languages. ISO-9 transliteration for Cyrillic (Russian only) is in there too, but I haven’t really made any serious attempt to test that yet. It also supports users adding their own transliterations.

related entries: Programming


20th July 2005 permanent link

I feel terrible today – some kind of summer virus I picked up from Jack (thanks Son). I went to work though, because this is only my third week in a new contract and I have a couple of important things that have to be finished. Now, if I’m serious about my yoga then this arguably violates the principle of ahimsa, non-harming. Forcing myself to work when I’m sick is clearly harming myself. On the other hand, letting my new colleagues down early in a new project conflicts with my longer term duty to provide for my family. That’s not about losing one billable day, it’s about reputation.

Of course feeling lousy at work for a day or two because of unfortunate timing simply isn’t a big deal in the grand scheme of things.

David “I never missed a day’s yoga practice in thirty years” Williams says skipping practice when you are sick is exactly the wrong thing to to – that’s when your body most needs to be energised and cared for by yoga practice. That doesn’t necessarily mean two hours of heinously advanced asana contortions though. The place where I’m working has a company gym, with an aerobic studio that’s used for classes in the evenings but generally quiet the rest of the time, so I’ve been doing my yoga practice in there at lunchtimes.

Today’s “practice” consisted of half an hour’s lying down relaxation followed by a few simple breathing exercises. (And it’s surprising how uncomfortable for the lower back it is to just lie down on a hard floor when you haven’t got everything warm and loose with asana practice first. It’s ok after a few minutes though). Better than nothing? Probably. Better than a day in bed with Harry Potter and the Half-Blood Prince and a large pot of ginger tea with honey, lemon and whisky? Probably not.

related entries: Yoga

commercial policy

20th July 2005 permanent link

It seems to be quite the thing lately for bloggers to complain about being “spammed” by marketing and PR people. I have mixed views on this.

I get a lot of requests for links from commercial yoga sites. These I generally ignore or politely decline – the latter if the people concerned have made the effort to write personally rather than just indiscriminately spamming me. I make exceptions for sites like Purple Valley Yoga, where they have yoga interests very close to my own and I know from other sources that they have a good reputation.

I would gladly prostitute myself for photographic toys, but sadly nobody has ever taken me up on my offer to do so.

And the other day I got a mail from Ross Stensrud of Fortuna Classical, whose company apparently makes an audiophile-grade hard disk jukebox that comes preloaded with classical music metadata. As Ross says, this is exactly what I described last year:

Somebody who is willing to spend … thousands of dollars for a … digital jukebox might well also want it to come with some decent metadata  (i.e. not the crap that is in CDDB) pre-loaded rather than having to key everything in themselves from scratch.

I’ve never used Fortuna’s products, and the only piece of audio gear I might personally be in the market for right now is an Airport Express. But since Ross has made the effort to search for websites that might be relevant to his products, actually read them (this is the crucial step, folks) and send individual emails, I wish him every success.

related entries: Music Photography Yoga

one simple & obvious way

18th July 2005 permanent link

One of the key qualities of python is supposed to be (and is, mostly) its cleanness and elegance. In contrast to perl, where no two programmers are ever supposed to do the same thing in the same way, in python there’s supposed to be “one simple and obvious way to do it”. Let’s look at this, for a couple of different values of “it”.

I discovered when I profiled my current project that it spends nearly half its time in a single function, and that function spends most of its time on a very common and obvious python programming scenario:

you want to look something up in a dictionary, but it might not be there

What’s the one simple and obvious way to do this? There are three. (At least).

Another python programming principle, we are often told, is it is easier to ask forgiveness than permission. So just try it, then worry about what to do if it fails:

    value = d[key]
except KeyError:
    value = default

That should work nicely as long you’re expecting to usually find what you’re looking for. If your expected hit rate is low (it isn’t in my particular situation, but it could be), then instead of raising lots of exceptions it might be better to look before you leap:

if key in d:
    value = d[key]
    value = default

But wait. We are also told we should use built in functions from the core python libraries wherever possible, because they are written in C code that is highly optimised and more efficient than anything we are likely to come up with ourselves. And Alex Martelli in Python in a Nutshell points out that python dictionaries have a get method that deals with precisely this situation:

value = d.get(key, default)

That saves us three lines of code (succinct is always good, right?) and should be at least as fast as the other two, if not even somehow magically faster. Er, no, as it turns out:

from time import time
lookups = 10000

hitrates = (1.00, 0.99, 0.9, 0.75, 0.5, 0.1)
for hitrate in hitrates:
    d = dict([(i,i) for i in range(1, lookups * hitrate)])
    start = time()
    for i in lookups:
            value = d[i]
        except KeyError:
            value = 0
    print 'Hit rate %f -- time for *try*: %f' % (hitrate, (time() - start))
    start = time()
    for i in lookups:
        if i in d:
            value = d[i]
            value = 0
    print 'Hit rate %f -- time for *if*: %f' % (hitrate, (time() - start))
    start = time()
    for i in lookups:
        value = d.get(i, 0)
    print 'Hit rate %f -- time for *get*: %f' % (hitrate, (time() - start))

10,000 dictionary lookups with various hit rates. Times in milliseconds, with python 2.3 running on a 1 GHz Powerbook with OS X 10.3.9:

Hitrate try if get
100% 21 29 30
99% 22 28 30
90% 22 27 29
75% 59 25 28
50% 116 23 28
10% 193 17 26
python dictionary lookup timings

try turns out, not surprisingly, to be the fastest approach if you’re sure what you’re looking for will nearly always be there. This is probably the normal case. Once your hit rate drops off a few percent, though, the cost of raising and handling all those exceptions becomes catastrophic, and then it’s faster to look before you leap. get is always slightly slower than look before you leap. Presumably it’s doing the same thing plus some overhead for the function call. I find it hard to see what it’s there for – why clutter up the standard library with a function that saves three simple & obvious lines of code at the expense of mediocre performance?

What about another common and obvious programming scenario?

you want to develop something that has a web front end

What’s the one simple and obvious way to do this? Zope? Webware? CherryPy? Quixote? Twisted? Subway? (…)

related entries: Programming

checkpoint charlie

6th July 2005 permanent link

Big happenings in Berlin I was barely aware of because I was busy doing yoga: apparently there was a concert of some kind on Saturday.

And last Thursday I walked by Checkpoint Charlie and admired an informal memorial that had been erected to Berliners murdered by the East German communist dictatorship. The friend I was with told me the memorial was controversial, but didn't know the Berlin city government was planning a dawn raid to destroy it on Monday. According to German news site Davids Medienkritik Thomas Flierl, the Berlin city senator most hostile to the monument, is a former senior member of the East German communist dictatorship. (If Berliners want to elect such people to their city government, that is of course up to them. But then they shouldn't be surprised when they behave in an, er, autocratic manner)


5th July 2005 permanent link

The “ashtanga” in “ashtanga vinyasa yoga” – the style of yoga I practice – means “eight limbs”, and refers to the eight limbs of classical yoga as described in the Yoga Sutras of Patanjali.

The Yoga Sutras are about two thousand years old, give or take a few hundred years. (I’m writing this on the train, without access to textbooks or the internet). They are mainly about the mental states associated with, and obstacles to, advanced meditation. Asana – yoga postures – is mentioned as the third of the eight limbs, but only very briefly: three verses out of a hundred-odd.

There are Indian carvings that appear to be of gods sitting in yogic meditation postures from thousands of years before Patanjali, but the first written records we have of anything resembling the elaborate physical postures and breathing exercises most people in the west now associate with the word “yoga” are much later – the Hatha Yoga Pradipika and related texts are only about six hundred years old. It’s entirely possible that earlier written texts existed but have been lost, or that the Hatha Yoga Pradipika etc. recorded practices that were already ancient oral traditions; but there’s no proof of it.

So did Patanjali practice anything that outwardly resembled what we now call “ashtanga vinyasa yoga”? Probably not. I would be quite surprised to see video footage – or even ink-on-palmleaf drawings – of him demonstrating the modern ashtanga sixth series.

How, then, does an outwardly very physical and even athletic-looking practice like modern “ashtanga vinyasa yoga” relate to the eight limbs of classical yoga as recorded by Patanjali? It’s a legitimate question, quite often asked by sceptical practitioners of other forms of yoga and meditation. Here's how.

For the point I want to illustrate I’ll skip over limbs one, two and four – yama, niyama and pranayama – although they’re involved too – and cut to limb five, pratyahara. Normally translated into English as “sense withdrawal”, pratyahara is about transferring one’s attention from what is going on in the outside world, to whatever the yogi’s chosen object of attention might be. That is the beginning of learning to direct and sustain the mind’s focus, and hence of meditation. In asana-oriented physical yoga practices, the chosen object of attention is the body and what we’re trying to do with it.

Several of the asanas in the ashtanga yoga primary series involve having one foot in half lotus postion, and then either reaching round and holding the toe from behind, or clasping the hands behind the back. Because I had tight hips and shoulders and a bad knee when I started yoga, getting into these positions was very slow and difficult for me. In most of them I still can’t just grab the foot or the opposite hand without having to think about it and grope around a bit. And here comes the pratyahara bit: it occurred to me recently that while I’m doing that, I can’t see my foot or my hand. And I don’t see anything else either. My eyes are open, and presumably they’re generating signals up the optic nerve and into the visual centres of my brain as usual, but my consciousness is paying no attention to them whatsoever. It’s fully focused on where the reaching hand is in relation to the other hand or that elusive lotus foot, with no attention to spare for anything else.

ardha badha padma padmotasana

ardha badha padma padmotasana

It’s at that moment of reaching my way into difficult postures that I first noticed this, but in fact it happens or should happen throughout the practice. Each posture in the ashtanga series comes with a specified driste, or point you’re supposed to be looking at – your toes, your hands, your navel … . The point isn’t that you’re supposed to really be looking at and paying attention to these things – although hanging on to a point on the wall with your eyes can help a lot in some difficult balancing postures – it’s more about reminding you that you shouldn’t be looking around at your own posture in the mirror (it doesn’t matter what you look like) or the babe on the next mat (it doesn’t matter what she looks like either). Your eyes are open and pointed at something, but that isn’t what you’re paying attention to.

Yoga is clever. I once attended a yoga course that was hosted in an Anglican convent in England, and got talking to one of the sisters. I asked her whether she thought it was incongruous for a course in yoga – rooted as it is in Hindu traditions – to be taking place in a Christian setting. She said she didn’t find it so. Christianity has meditative, mystic traditions that are basically the same thing, but in Christianity there is no help or advice on how to go about pursuing meditation, or “contemplative prayer”, in a systematic way. You’re just supposed to sit down, still your mind (how?) and be open to grace. The sister said what she found fascinating about buddhism and yoga is that they, over several millenia, have assembled a whole collection of tricks and techniques for helping a still and open mind to happen, different ones of which work for different people.

related entries: Yoga

david williams notes

4th July 2005 permanent link

Key messages from the course I attended with David Williams in Berlin at the weekend: physical yoga practice is just a way, one of many, to arrive at a state of meditation. The focus of attention in ashtanga vinyasa practice should be mula bandha and breath. What the asanas look like isn’t important, and in any case should be adapted to the needs of the student and will be different for everybody.

You can achieve enlightenment through yoga without ever having sat in lotus position or stood on your head.

Don’t hurt yourself in pursuit of an outwardly advanced-looking practice. People who are attracted to asthanga are generally Type A, ambitious, achievement-oriented and will push too hard. As an ashtanga teacher, David is forever trying to get students to back off; can’t remember ever having to tell somebody to stop slacking & try harder.

Don’t hurt yourself; don’t hurt other people either. There are teachers out there pushing their students too hard and injuring them.

[I’ve never seen this. I managed to hurt my knees all on my own trying to achieve lotus with poor technique, and I knew one person in Mysore who said Pattabhi Jois strained her hamstring. But I’m hearing quite a few people lately saying it's widespread and I have no reason to disbelieve them. I’ve never been involved in the intense big-city ashtanga scenes in places like New York or London]

David can say asana doesn’t matter and be listened to. He’s been there (years in Mysore), done that (the entire astanga advanced syllabus), got the teeshirt (there probably weren’t Ashtanga Yoga Research Insititute teeshirts in the 70s). Would students listen to a less qualified teacher who said it? Some – achievement-oriented ashtanga types – might take it as just somebody who can’t hack it making excuses. So in a sense paradoxically it does matter – if only for teaching, if only as a credential to be able to say it doesn’t matter.

I took lots & lots of notes. I was thinking of just editing them and sticking them up on the web, but I decided that wouldn’t be right. If you want to hear all of what David has to say, go to one of his courses. They’re well worthwhile.

related entries: Yoga

yoga for men

4th July 2005 permanent link

90% of 80 year old men have prostate problems, says David Williams. One yoga practice that is supposed to be very helpful for the prostate is janu sirsana b, where you bend forward over one leg whilst sitting with your perineum on the heel of the the other foot.

Like this, although you can’t see where the foot is from this angle:

Janu Sirsana B

David says he learned this from Pattabhi Jois, then had it confirmed by a student who had prostate cancer whose oncologist recommended sitting with his perineum on a tennis ball.

Hmm. This is one that I tend to skip if I’m short of practice time, because it’s physically one of the easiest things in primary series for me. I’m a typical type A ashtangi – why relax and do something easy when you could be struggling with the next difficult thing? Clearly that needs to change – I’m only 44, but it’s never too soon to start taking proper care of yourself.

David also very strongly recommends doing stomach lifts and nauli as a general abdominal toning exercise. I don’t recall him saying anything specifically about the prostate in connection with this, but another teacher I know, Raphael da Bora, did. I do nauli occasionally when I feel like it, but not on anything like a daily basis. That, too, needs to change.

UPDATE: and if you want to avoid a whole host of prostate, bladder and bowel problems (it’s nearly 40 years too late to avoid appendicitis in my case), then don’t sit, squat.

related entries: Yoga

tour de france, tour de france

3rd July 2005 permanent link

I’ve never been a competitive cyclist myself, but one of my best friends at university was and I’ve been fascinated by the Tour de France ever since. Today’s Berliner Tagesspiegel has an interview with top German rider Jens Voigt that’s the most interesting insider perspective on the Tour I’ve ever read.

A few interesting snippets: Voigt is a lone break specialist. The best time to attack and get away is just after an intermediate sprint, when everybody is winded and eases off for a moment. There are other times when everybody eases off but it’s absolutely taboo to attack: at feeding stations; when the yellow jersey has stopped for a piss …

When he’s establishing a break, Voigt rides at 55 kilometres an hour (a hair under 40 mph). Nobody can keep that up for long, but it’s psychologically very important to get out of sight quickly. Once he’s out there on his own, he knows he’s a minute per 10 km slower than the pack if they do decide to haul him in, although they’re unlikely to bother if it won’t materially affect the overall leader board. So 20 km out, he knows if he has a 3 minute lead he’s probably won the stage. 2 minutes and it’s 50-50. Less than two minutes forget it.

It's long and I’m not going to even think about trying to translate the whole thing, but if you’re interested and can read German (or are curious to see what Google or Babelfish makes of it) it’s well worth seeking out.

UPDATE 10th July: that’s “yellow jersey holder Jens Voigt”, although probably not for long. After the rest day tomorrow, the to Tour goes to the Alps on Tuesday; Voigt has little chance of staying ahead of Lance for long on the big climbs. Today’s stage winner, Danish mountain specialist (!??) Mickael Rasmussen, could keep the race interesting for antoher day or two; he’s in fourth place overall, less than thirty seconds behind Lance. Lance, like all great Tour champions, has consistently shown the ability to beat mountain specialists at their own game – but even he can’t necessarily do it every day.

yoga workshop pictures

3rd July 2005 permanent link

Just returned from a great weekend in Berlin, attending a weekend course with David Williams. David is one of the most experienced western ashtanga vinyasa yoga practitioners who first learned the system in the mid ’70s. Interesting perspectives, quite significantly different from how a lot of people are approaching their yoga these days.

Notes to follow, meanwhile here are some pictures.

David Williams

Many thanks to David, and to Henning of the Prenzlauer Berg Yoga Shala who organised the event.

This is one of the great beauties of digital photography. The event finished this morning, and the same day I have the pictures edited on the flight home and ready go to on the web. Try doing that with film. I used to be able to go the the lab to drop film off, go to the lab again to collect it, spend a whole evening scanning film (and did anybody, ever, not hate doing that?) and have the pictures up within a few days; but that was before I was a father. It would never happen now.

related entries: Yoga Photography

berliner weisse

1st July 2005 permanent link

I am in Berlin for a yoga course. I like Berlin. Attending a yoga course doesn’t completely preclude going out for a beer or two with the friend I’m staying with, at least not when the first two days of the yoga course are evening-only sessions. And despite not being in Bavaria, Berlin has its own rather fine beer speciality.

Berliner Weisse is a very light, spritzy, slightly sour wheat beer. It’s served in small glasses, normally with a shot of pink or green fruit syrup. You can order it without, but if you do the waitress gives you a funny look. Berliner Weisse goes back over two hundred years – Napoleon is said to have been a fan. And normally, when somewhere has a local speciality beer, it’s traditionally the working man’s drink.

But when I ordered mine (green) last night, it arrived with a straw. And here’s what I’m really having great difficulty imagining: in the late nineteenth century, when Berlin was one of the industrial powerhouses of the world, horny-handed Prussian engineering workers after a hard day at the Siemens factory, heading to the pub of an evening to drink little pink and green fizzy drinks with straws.

all text and images © 2003–2008

< june 2005 august 2005 >