python implementation of map reduce