Actually, if we can take them at their word, they would have beaten us by only 1 or 2 turns. Micromanagement of Shen Ling and possibly even Zhi Gang (after it grows next turn) and increasing the tech rate to 100% might have narrowed the gap to 1 turn, but it was unlikely.
As it was, we were 2 turns behind when I switched research to Mysticism (before dropping the tech rate). Furthermore, to keep pace, we would have had to delay the production of our settler in Shen Ling. I think this deal will pay off for us in the long run, even if it dampens our chances of getting the Great Library.