Should I use a dictionary?

Jeff Shannon jeff at ccvcorp.com
Wed Jun 27 13:22:25 EDT 2001


Gustaf Liljegren wrote:

> "As Kosh said, it will improve performance to do the sorting with integers.
> You're right that it may be confusion, but I think a comment in the right
> place will prevent that. :-) After doing the sorting, the integer is to
> be transformed into a date again, using the mkdate function:
>
> d = time.mkdate((date[:4],date[5:6],date[7:8],date[9:10],date[11:12]))
>
> The remaining question is if the time saved on sorting integers is more than
> the time it takes to convert from and to a date before and after sorting.
> I'll try this later today.

Any particular reason to recreate the date, instead of grabbing it out of the
message again?  I would think that leaving the original date intact, and using
a strptime()'d copy of it as your sorting index, would be the best solution.
Then you can throw away the sorting index once the list is sorted, and you
still have a useable date in your data.   Of course, if you'd still need to
convert
to a different date format than your source data, the benefits of doing this
would diminish considerably....

Jeff Shannon
Technician/Programmer
Credit International






More information about the Python-list mailing list