China's Teng Hsiao-ping came to Japan a mystery man last week and left with a quickly won reputation as a masterful diplomat, a font of folksy wisdom and disarming wit, and a model of sagacity, candor and tact.

Remarkably and ironically, Teng appeared to offend no one except Japan's Communists and Socialists. He ignored the former during his eight-day visit and outraged the latter by saying that China's present rulers have no objection to Japan's military alliance with the United States.

Teng's embrace of all others in Japan tended to obscure the fact that, on the surface at least, nothing was accomplished or changed by his visit. It ended yesterday.

Teng was as tough as ever on the question of U.S. relations with Taiwan. He virtually begged for Japan's assistance in modernizing China, but said nothing about how China intends to pay for all of those plants and machines it wants to buy here.

It was simply a goodwill visit, intended to tap that latent Japanese affection for China that existed for many centuries, and it accomplished just that.

The Japanese, who do not like surprises, were apprehensive of his visit. A survivor of 40 years of war, revolution, intrigue and purges, the deputy prime minister was reputed to be an earthy, blunt, enigmatic man who spits a lot into spittoons.

Would Teng, the Japanese wondered, open old wounds with reminders of Japan's invasion in the 1930s?

"Let bygones by bygones," he told Emperor Hirohito.

Would he lay claim to the Senkaku Islands, which Japan also claims? Let the next generation worry about the Senkakus, said Teng.

The performance pleased almost everyone, from Prime Minister Takeo Fukuda down.

"He is genuinely interested in Japan," said a Nissan Motor Co. executive after showing Teng the factory. "He was asking things like, "What kind of education do those men on the assembly line have?"

Teng praised Japan's automobiles, bullet trains, autumn foliage and Mount Fuji, and the man in the street was struck by his youthful vigor.

"Cute! cute!" someone in a crowd murmured as Teng, a man of small stature, left a building in downtown Tokyo.

"He has aroused the pro-Chinese sentiment in the Japanese," summed up Keio University president Tadao Ishikawa, a China scholar.

What struck many was Teng's determination to meet and chat with those unofficial Japanes who were friends of China before the present government grudgingly moved to sign the peace treaty he came to celebrate. He insisted on seeing the disgraced former prime minister, Kakuei Tanaka, and he paid a special call on aging business leaders who had tried to establish relations with China as long as the 1950s.

"When you are drinking water," Teng explained, quoting the late prime minster Chou En-lai, "don't forget the people who dug the well."

Playing diplomat is a new role for the 74-year-old twice-purged Chinese leader. In Peking he is known as the pragmatic architect of the new modernization, which is designed to make China an economic power by the end of this century, and as the chief purger of former enemies, the "Gang of Four." But this year he also has become China's emissary to the rest of Asia. He has already visited Burma, Nepal and North Korea and soon takes his show to Malaysia, Singapore and Thailand.

His travels are an essential part os the thaw in China, an effort to show that the Chinese are truly coming out of their shell after the purges and rebellions. Chairman Hua Kuo-feng went to Eastern Europe, Chinese trade missions are heading for Europe, and numbers of students may go to Japan and other countries. There is even a Chinese team in Tokyo studying baseball. It is China's proof to the world that the old days of spurning foreign ways are gone.

An unusual feature on this trip was the presence of Teng's wife, Cho Lin, who performed the duties that might be expected of the wife of a traveling leader of any country. She visited a school, dispensed some pretty Chinese scrolls, and like her husband, tromped through a steel mill wearing a revolutionary-red hard hat.

Since the Cultural Revolution began in 1966, no Chinese leader had traveled abroad with his wife until recently. One reason was the unfortunate experience of Wang Kuang-mei, who had gone with her husband, then president Liu Shao-chi to Indonesia in 1966. She was pilloried by Cultural Revolution wall posters for having worn a silk dress on that trip, and the Red Guards accused her of having used the dress to flirt with Indonesia's President Sukarno.

Cho may have had that experience in mind on this trip. She wore trousers and jacket, possibly to satisfy the proletarian tastes back home, but they seemed to observers to be tastefully designed and elegantly embroided to meet the social requirements for an ambassador's wife.