Re: Convert month name to month number faster

2011-01-24 Thread Crawford, Ellen
-- http://mail.python.org/mailman/listinfo/python-list

RE: Convert month name to month number faster

2010-01-06 Thread jfabiani
python.org > [mailto:python-list-bounces+ntb837=motorola@python.org] On Behalf Of > wiso > Sent: Wednesday, January 06, 2010 4:34 PM > To: python-list@python.org > Subject: Convert month name to month number faster > > I'm optimizing the inner most loop of my script

Re: Convert month name to month number faster

2010-01-06 Thread Steven D'Aprano
On Wed, 06 Jan 2010 12:03:36 +0100, wiso wrote: > I'm optimizing the inner most loop of my script. I need to convert month > name to month number. I'm using python 2.6 on linux x64. According to your own figures below, it takes less than a nanosecond per lookup, at worst, even using a remarkably

Re: Convert month name to month number faster

2010-01-06 Thread wiso
Antoine Pitrou wrote: > 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

Re: Convert month name to month number faster

2010-01-06 Thread alex23
On Jan 6, 9:03 pm, wiso wrote: > I'm optimizing the inner most loop of my script. I need to convert month > name to month number. I'm using python 2.6 on linux x64. > > month_dict = {"Jan":1,"Feb":2,"Mar":3,"Apr":4, "May":5, "Jun":6, >            "Jul":7,"Aug":8,"Sep":9,"Oct":10,"Nov":11,"Dec":12}

Re: Convert month name to month number faster

2010-01-06 Thread Antoine Pitrou
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.__geti

RE: Convert month name to month number faster

2010-01-06 Thread VYAS ASHISH M-NTB837
Behalf Of wiso Sent: Wednesday, January 06, 2010 4:34 PM To: python-list@python.org Subject: Convert month name to month number faster I'm optimizing the inner most loop of my script. I need to convert month name to month number. I'm using python 2.6 on linux x64. month_dict = {"Jan&

Convert month name to month number faster

2010-01-06 Thread wiso
I'm optimizing the inner most loop of my script. I need to convert month name to month number. I'm using python 2.6 on linux x64. month_dict = {"Jan":1,"Feb":2,"Mar":3,"Apr":4, "May":5, "Jun":6, "Jul":7,"Aug":8,"Sep":9,"Oct":10,"Nov":11,"Dec":12} def to_dict(name): return month_dic