Add Python implementation of SOS