python 2.6-removing and counting duplicates in a list of dictionaries effeciently
<p>I'm trying to efficiently change:</p>

<pre><code>[{'text': 'hallo world', 'num': 1}, 
 {'text': 'hallo world', 'num': 2}, 
 {'text': 'hallo world', 'num': 1}, 
 {'text': 'haltlo world', 'num': 1}, 
 {'text': 'hallo world', 'num': 1}, 
 {'text': 'hallo world', 'num': 1}, 
 {'text': 'hallo world', 'num': 1}]
</code></pre>

<p>into a list of dictionaries without duplicates and a count of duplicates:</p>

<pre><code>[{'text': 'hallo world', 'num': 2, 'count':1}, 
 {'text': 'hallo world', 'num': 1, 'count':5}, 
 {'text': 'haltlo world', 'num': 1, 'count':1}]
</code></pre>

<p>So far, I have the following to find duplicates:</p>

<pre><code>result = [dict(tupleized) for tupleized in set(tuple(item.items()) for item in li)]
</code></pre>

<p>and it returns:</p>

<pre><code>[{'text': 'hallo world', 'num': 2}, 
 {'text': 'hallo world', 'num': 1}, 
 {'text': 'haltlo world', 'num': 1}]
</code></pre>

<p>THANKS!</p>
