Iran went to great lengths today to stress its view that the freeing of its diplomats in London and the condition of the American hostages held here were in no way comparable.

President Abol Hassan Bani-Sadr and Foreign Minister Sadegh Ghotbzadeh claimed the heroism of Britain's elite Special Air Services was a "victory" for Iran and Islam.

Bani-Sadr, in a second message to the British government, thanked Prime Minister Margaret Thatcher, "for the steadfast acts of the police of your country . . . in this affair of the unjust hostage taking at the Iranian embassy in London. . . ."

A midday commentary on official Tehran radio insisted that the two cases involving diplomatic hostages were "as different as the earth is from the sky," and this evening Ghotbzadeh explained why on television.

"If a foreigner came to Iran and took over the American Embassy and asked for the separation of California from the United States that would not be acceptable," he said. That was his way of explaining why Iran ruled out the London terrorists' demands concerning the oil-producing province of Khuzestan, which has a large Arab minority.

Stressing the "irrelevant comparison" between the two cases, the radio commentary reiterated the now familiar theme that the seizure of the American Embassy here represented "the will of the oppressed nation against U.S. domination" and "demonstated the ugly reality that hides behind the curtain of diplomatic immunity."

The Iranian government's and the London hostages' acceptance of their possible martyrdom -- a constant theme in Shiite Islam, which is the state religion of Iran -- "was finally able to overcome darkness and ruin," the radio commentary added.

It insisted that unlike the case of the American hostages accused of spying here, the London diplomats had "no other duties but to represent their country" and "were taken hostage by a group of hired and deceived terrorists" in the pay of Iraq.

The official comment differed sharply from the anti-British attacks in Islamic Republic, the organ of the right-wing clerical Islamic Republican Party.

Setting the tone was its front-page headline, which ran a banner streamer charging the Central Intelligence Agency and British intelligence "mercenaries" were responsible for blowing up the Iranian Embassy in London.

The British Embassy, whose chancery was sacked and burned in November 1978, has also been under threat lately from the Marxist Fedayan guerrilla group.

Nonetheless, embassy sources said that two dozen Iranians called at the embassy to express thanks for the ending of the London seige, while an equal number telephoned.

[President Carter praised the British government for what he called its responsible handling of the hostage crisis and its regard for human decency and international law, which he said contrasted with the "terrorist" attack on the U.S. embassy in Tehran Nov. 4.]

Meanwhile, a new wave of executions was announced by the revolutionary courts, bringing to about 800 the number of Iranians killed in this fashion since the revolution triumphed in February 1979.

The latest to be shot were seven men who were accused of plundering property, aiding Israel and maltreating of opponents of the now-deposed shah Mohammad Reza Pahlavi.

Judging by the description of the charges, many appeared to be members of the Bahai faith, a breakaway sect that Shiite Moslems consider apostate.

Another Bahai, Farrokhrou Parsa, the former minister of education from 1968 to 1974, became the first prominent woman politician sentenced to death by a revolutionary court. The onnly woman known to have been executed by the revolutionary court so far were prostitutes or brothel-keepers.

The office Pars news agency announced today that Revolutionary Guards in Tehran had arrested an unidentified American woman who had confessed she was a CIA agent.

Iranian media today revealed the assassination in the holt city of Qom of Hojawtoleslam Morteza Mahmoudi, chief assistant of Ayatollah Khazem Shariatmadari. Shariatmadari is the leader after Ayatollah Ruhollah Khomeini and has often opposed his policies.