Moved the Python castings to the variables implementation