--
http://mail.python.org/mailman/listinfo/python-list
VYAS ASHISH M-NTB837 wrote:
>
> How about using list.index() and storing month names in a list? You may
> want to measure performance your self and conclude.
>
> Regards,
> Ashish Vyas
>
> -Original Message-
> From: python-list-bounces+ntb837=motorola@python.org
> [mailto:python-li
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
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
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}
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
How about using list.index() and storing month names in a list? You may
want to measure performance your self and conclude.
Regards,
Ashish Vyas
-Original Message-
From: python-list-bounces+ntb837=motorola@python.org
[mailto:python-list-bounces+ntb837=motorola@python.org] On Beh