"Newbie" questions - "unique" sorting ?

Cousin Stanley CousinStanley at hotmail.com
Wed Jun 25 11:40:30 EDT 2003


| Which is probably correct since that would be equivalent to:
|  not dict_words.has_key(this_word)
|
| But if you look at the above code mentioned - it doesn't do that -
|
| it calls .keys() [generating a list]
| and then looks if the string is in it...

Kim ...

I changed one line in the script ....

    from .... if this_word not in dict_words.keys()  :

    to ...... if not dict_words.has_key( this_word ) :

The results are a little MORE than satisfactory,
running in 48 seconds instead of 7 hours !!!!

     Complete .................

         Total  Words .... 467381

         Unique Words .... 47122

     Process Time ........ 48.11  Seconds


I failed to consider here
that a  NEW  keys list might be created
on each pass through a loop ....

Thanks VERY MUCH for the suggestion ....

-- 
Cousin Stanley
Human Being
Phoenix, Arizona






More information about the Python-list mailing list