We do not often have the opportunity to look into how top judges take their decisions in important cases. I don't mean the justifications provided for public consumption in their official judgments – those are merely the conclusions, in legal jargon – but what went on beforehand, in their minds, emotions and consciences?

Albie Sachs, soon to retire as a judge of the South African constitutional court, has more reason than most to consult his complex hinterland when faced with making up his mind about a case before the court which could affect thousands, even millions of people.

His CV includes a spell in a South African jail and he survived an assassination attempt by the apartheid-era South African special branch, which cost him an arm and the sight of an eye.

The Strange Alchemy of Life and Law, published this week (Oxford University Press), is his fascinating and honest account of how his own thinking, emotions and experiences contributed to some of the most startling, original, adventurous, far-reaching and moving decisions taken by any court in the world. The constitution which the judges had to interpret was a new one, custom-built to deal with the post-apartheid South Africa. Their decisions showed the same freshness.

There may be stern legal commentators who believe that the constitutional court judges have occasionally allowed their feelings, and that special humanity shared by all who suffered under or fought against apartheid, to affect their strict legal analyses. Sachs doesn't deny the charge, makes no apology for it, and doesn't see how it could have been otherwise: "I have no doubt that life experiences have entered my legal consciousness in multiple ways, some very obvious and others quite mysterious."

That doesn't mean that he or his fellow judges placed their desire to do justice to sympathetic individuals above their judicial duty to apply what the constitution laid down. But somehow they often managed to interpret the law imaginatively, in such a way as to help the suffering and the disadvantaged.

One striking example of their dilemma arises from that part of the constitution which grants socio-economic rights. For instance, it gives everyone the right of access to housing, healthcare, food and water; and says the state "must take reasonable legislative and other measures, within its available resources, to achieve the progressive realisation" of those rights.

But how can a court possibly enforce such a right? In effect, the judges were being asked to make sure the government kept its political promises to provide better housing, healthcare, etc.

In one of its most sensational judgments, the court ruled the government was obliged to provide the antiretroviral drug Nevirapine to pregnant women with HIV in hospitals. The government's lawyer had argued that health policy was for the government to decide. But Sachs and his colleagues found a way of interpreting the constitution to do what they felt was right – and probably saved thousands of lives as a result.