That is the question you really need to answer.
Is it better to stop future offending or feel good about inflicting suffering on others who are "bad" right now?
You might also want to throw into the mix the observation that a very large number of people in prison have untreated mental / behavioral issues and that a very large number of people who commit violent or sexual crimes have themselves been victims of such crimes in their formative years.
My argument is that whatever your ethics are, treating people like animals creates more animals. We all pay the cost of that.