Eyebrows were raised when Shanghai took part in the OECD's Programme for International Student Assessment (Pisa) for the first time and came top in maths, science and reading tests.
Cheng Kai-Ming, professor of education at Hong Kong University, who is closely involved in the Hong Kong and Shanghai tests, puts the results down to "a devotion to education not shared by some other cultures".
Under the banner of "First class city, first class education", Shanghai set about systematically re-equipping classrooms, upgrading schools and revamping the curriculum in the last decade.
It got rid of the "key schools" system which concentrated resources only on top students and elite schools. Instead, staff were trained in more interactive teaching methods and computers were brought in.
Shanghai controls who lives and works in the city through China's notorious "houkou", or permanent residency system, allowing only the best and the brightest to become residents with access to jobs and schools.
Andreas Schleicher, of the OECD, believes teacher training has played a part, with higher-performing teachers mentoring teachers from lower- performing schools.
"What is striking about Shanghai is that there is quite a large socio- economic variability in the student population, but it does not play out in terms of its Pisa results," he said.
Professor Cheng points out that the majority of migrant children are below the age of 15. "If they were allowed to attend senior secondary schools in the city, the results would be very different."