worry
the original might be changed out from under.
My apologies if it was understood to mean I had shown it was copied.
-Original Message-
From: Python-list On
Behalf Of Stefan Ram
Sent: Tuesday, October 12, 2021 9:49 PM
To: python-list@python.org
Subject: Re: sum() vs. loop
&quo
On Mon, 11 Oct 2021 at 23:00, Christian Gollwitzer wrote:
>
> Am 10.10.21 um 10:49 schrieb Steve Keller:
> > I have found the sum() function to be much slower than to loop over the
> > operands myself:
> >
> > def sum_products(seq1, seq2):
> > return sum([a * b for a, b in zip(seq1, seq2)])
>
On Wed, Oct 13, 2021 at 12:36 PM Avi Gross via Python-list
wrote:
>
> Alan,
>
> I am also wondering about that zip() function call to bind the two lists
> into a sort of iterator object. Presumably that calls the iterator N times.
> I did a test where I made two list called A and B and used zip to
.
-Original Message-
From: Python-list On
Behalf Of Alan Gauld
Sent: Tuesday, October 12, 2021 6:56 PM
To: python-list@python.org
Subject: Fwd: Re: sum() vs. loop
On 10/10/2021 09:49, Steve Keller wrote:
> I have found the sum() function to be much slower than to loop over
> the op
Am 12.10.21 um 05:41 schrieb Dan Stromberg:
On Mon, Oct 11, 2021 at 2:54 PM Steve Keller wrote:
I have found the sum() function to be much slower than to loop over the
operands myself:
def sum_products(seq1, seq2):
return sum([a * b for a, b in zip(seq1, seq2)])
def sum_products2(seq1,
On 10/10/2021 09:49, Steve Keller wrote:
> I have found the sum() function to be much slower than to loop over the
> operands myself:
>
> def sum_products(seq1, seq2):
> return sum([a * b for a, b in zip(seq1, seq2)])
>
> def sum_products2(seq1, seq2):
> sum = 0
> for a, b in zip(seq1, seq2):
> s
On Mon, Oct 11, 2021 at 2:54 PM Steve Keller wrote:
> I have found the sum() function to be much slower than to loop over the
> operands myself:
>
> def sum_products(seq1, seq2):
> return sum([a * b for a, b in zip(seq1, seq2)])
>
> def sum_products2(seq1, seq2):
> sum = 0
> for a, b
On Tue, Oct 12, 2021 at 9:02 AM Stefan Ram wrote:
>
> Steve Keller writes:
> >Now completely surprised.
>
> I have observed that here the generator-based sum() call
> is slower if both seq1 and seq2 have a length of 1000, but
> faster if both seq1 and seq2 have 1000 entries each
> (wi
On Tue, Oct 12, 2021 at 8:55 AM Steve Keller wrote:
>
> I have found the sum() function to be much slower than to loop over the
> operands myself:
>
> def sum_products(seq1, seq2):
> return sum([a * b for a, b in zip(seq1, seq2)])
>
> def sum_products2(seq1, seq2):
> sum = 0
> for a, b
Christian Gollwitzer writes:
> > def sum_products(seq1, seq2):
> > return sum([a * b for a, b in zip(seq1, seq2)])
> > def sum_products2(seq1, seq2):
> > sum = 0
> > for a, b in zip(seq1, seq2):
> > sum += a * b
> > return sum
> > [...]
>
> The first version construct
Am 10.10.21 um 10:49 schrieb Steve Keller:
I have found the sum() function to be much slower than to loop over the
operands myself:
def sum_products(seq1, seq2):
return sum([a * b for a, b in zip(seq1, seq2)])
def sum_products2(seq1, seq2):
sum = 0
for a, b in zip(seq1, seq2):
11 matches
Mail list logo