It is said in the Bhagavad Gita (chapter 2, verse 47):

yoga-sthah kuru karmani
sangam tyaktva dhananjaya
siddhy-asiddhyoh samo bhutva
samatvam yoga ucyate

A rough translation for this is:

Be steadfast in yoga, O Arjuna. Perform your duty without any attachment. Maintain an even mind in the face of success or failure. Such evenness of mind is called yoga.

Here, Krishna is instructing his student, Arjuna, to perform his duty while maintaining an even keel in the face of both success or failure.

Marcus Aurelius, in his Meditations (chapter 6), says:

When force of circumstance upsets your equanimity, lose no time in recovering your self-control, and do not remain out of tune longer than you can help. Habitual recurrence to the harmony will increase your mastery of it.

The practice of equanimity could also be thought of as a practice of not spending one’s energy and time unnecessarily in being ecstatic upon success and morose upon failure, both of which are ephemeral in the long run.

For some, maintaining equanimity in the face of both joy and sorrow may seem like it is a form of unnecessary “repression”. Any form of discipline undoubtedly has a component of undergoing temporary discomfort for long term gain. Such discipline can not only be physical but also mental.

For example, in order to lose weight and gain physical health, one must repress one’s urges to eat twenty cakes a day. Similarly in order to train one’s mind to gain mental health and avoid the trappings of modern day “psychologists”, one must repress the urge to react at the drop of a pin.