letter frequency counter / your thoughts..

castironpi at gmail.com castironpi at gmail.com
Wed May 7 20:11:14 EDT 2008


On May 7, 5:27 pm, "bruno.desthuilli... at gmail.com"
<bruno.desthuilli... at gmail.com> wrote:
> On 7 mai, 23:51, "bruno.desthuilli... at gmail.com"<bruno.desthuilli... at gmail.com> wrote:
>
> (snip)
>
> Small improvement thanks to Paul Rubin:
>
> from collections import defaultdict
> from operator import itemgetter
>
> def get_letters_frequency(source):
>     letters_count = defaultdict(int)
>     for letter in source:
>         letters_count[letter] += 1
>       return sorted(
>           letters_count.iteritems(),
>           key=itemgetter(1),
>           reverse=True
>        )

I have a bounce on mostfreq("abbcccddddeeeeeffffff").  It's more
useful when it runs in real time, i.e. persists.  Can I write database
code on time in a pickle?

serial= depickle( uniqueA )
serial.append( "a" )
repickle( uniqueA, serial )

I have to keep control during three ops.



More information about the Python-list mailing list