Python implementation of SFS