Convert month name to month number faster

Antoine Pitrou solipsis at pitrou.net
Wed Jan 6 06:53:46 EST 2010


Le Wed, 06 Jan 2010 12:03:36 +0100, wiso a écrit :


> from time import time
> t = time(); xxx=map(to_dict,l); print time() - t # 0.5 t = time();
> xxx=map(to_if,l); print time() - t   # 1.0

Don't define your own function just for attribute access. Instead just 
write:

xxx = map(month_dict.__getitem__, l)





More information about the Python-list mailing list