Migrate python implementation to pyutils