Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion sum function
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ian Kelly  
View profile  
 More options Oct 4 2012, 5:05 pm
Newsgroups: comp.lang.python
From: Ian Kelly <ian.g.ke...@gmail.com>
Date: Thu, 4 Oct 2012 15:04:53 -0600
Local: Thurs, Oct 4 2012 5:04 pm
Subject: Re: sum function

On Thu, Oct 4, 2012 at 2:52 PM,  <mike20...@gmail.com> wrote:
> scanner = client.scannerOpenWithStop("tab", "10", "1000", ["cf:col1"])
> total = 0.0
> r = client.scannerGet(scanner)
> while r:
>   for k in (r[0].columns):
>     total += float(r[0].columns[k].value)
>   r = client.scannerGet(scanner)

> print total

> Do you know of better (faster) way to do sum?

scanner = client.scannerOpenWithStop("tab", "10", "1000", ["cf:col1"])
next_r = itertools.partial(client.scannerGet, scanner)
total = sum(float(col.value) for r in iter(next_r, None) for col in
r.itervalues())

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.