Atlantic to Pacific through Panama means sailing southeast.
Panama curves so that the canal from the Caribbean to the Pacific runs roughly northwest to southeast, not east to west. Locks lift ships 26 metres up to Gatún Lake and lower them again on the other side. The roughly 80 km take about 8 to 10 hours. Sailing around South America instead would add around 13,000 km.
Useful: Check your mental map: the Pacific exit lies east of the Atlantic entrance.
Source: en.wikipedia.org