You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by hu...@apache.org on 2015/03/26 12:20:28 UTC

svn commit: r1669322 - /steve/trunk/pysteve/lib/plugins/fic.py

Author: humbedooh
Date: Thu Mar 26 11:20:28 2015
New Revision: 1669322

URL: http://svn.apache.org/r1669322
Log:
don't call nlargest on every turn, we don't need that

Modified:
    steve/trunk/pysteve/lib/plugins/fic.py

Modified: steve/trunk/pysteve/lib/plugins/fic.py
URL: http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/fic.py?rev=1669322&r1=1669321&r2=1669322&view=diff
==============================================================================
--- steve/trunk/pysteve/lib/plugins/fic.py (original)
+++ steve/trunk/pysteve/lib/plugins/fic.py Thu Mar 26 11:20:28 2015
@@ -68,7 +68,8 @@ def tallyFIC(votes, issue):
     
     # Start counting
     sorted_matrix = sorted(matrix.items(), key=operator.itemgetter(1))
-    winners = [l[0] for l in sorted_matrix if matrix[l[0]] in heapq.nlargest(numseats, matrix.values())]
+    bignums = heapq.nlargest(numseats, matrix.values())
+    winners = [l[0] for l in sorted_matrix if matrix[l[0]] in bignums]
 
     # Compile list of winner names
     winnernames = []



Re: svn commit: r1669322 - /steve/trunk/pysteve/lib/plugins/fic.py

Posted by Greg Stein <gs...@gmail.com>.
both loops ...

On Thu, Mar 26, 2015 at 6:20 AM, <hu...@apache.org> wrote:

> Author: humbedooh
> Date: Thu Mar 26 11:20:28 2015
> New Revision: 1669322
>
> URL: http://svn.apache.org/r1669322
> Log:
> don't call nlargest on every turn, we don't need that
>
> Modified:
>     steve/trunk/pysteve/lib/plugins/fic.py
>
> Modified: steve/trunk/pysteve/lib/plugins/fic.py
> URL:
> http://svn.apache.org/viewvc/steve/trunk/pysteve/lib/plugins/fic.py?rev=1669322&r1=1669321&r2=1669322&view=diff
>
> ==============================================================================
> --- steve/trunk/pysteve/lib/plugins/fic.py (original)
> +++ steve/trunk/pysteve/lib/plugins/fic.py Thu Mar 26 11:20:28 2015
> @@ -68,7 +68,8 @@ def tallyFIC(votes, issue):
>
>      # Start counting
>      sorted_matrix = sorted(matrix.items(), key=operator.itemgetter(1))
> -    winners = [l[0] for l in sorted_matrix if matrix[l[0]] in
> heapq.nlargest(numseats, matrix.values())]
> +    bignums = heapq.nlargest(numseats, matrix.values())
> +    winners = [l[0] for l in sorted_matrix if matrix[l[0]] in bignums]
>
>      # Compile list of winner names
>      winnernames = []
>
>
>