Should I use a dictionary?
gustafl at algonet.se
Wed Jun 27 11:39:16 CEST 2001
"Danyel Fisher" <danyelf at ics.uci.edu> wrote:
> > Thanks. This suits me perfectly. I get the date in the format
> > 13:12", so that would be "200101011312" with no risk for confusion.
> True. But you may still wish to consider UNIX standard date/time:
> it will make your data interprable in other contexts, should you need to.
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.
More information about the Python-list