On Mon, 27 Dec 2004 18:49:14 +0100, François Granger
<[EMAIL PROTECTED]> wrote:
> Le 27/12/04 1:03, « Ishwor » <[EMAIL PROTECTED]> a écrit :
>
> > so indeed method 2 (l2.extend() ) is the fastest ?? In 2/3 times,
> > method 3 (l3 += [x] seems faster than method 1/2 in my P2.4GHZ machine
> > with 5
Le 27/12/04 1:03, « Ishwor » <[EMAIL PROTECTED]> a écrit :
> so indeed method 2 (l2.extend() ) is the fastest ?? In 2/3 times,
> method 3 (l3 += [x] seems faster than method 1/2 in my P2.4GHZ machine
> with 512mb??? :-(
> Could u run the code in your machine and perhaps and let me know what
> the
"Ishwor" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
If you are curious about the detailed behavior of the CPython
implementation, the dis module is one aid. Compare
>>> def f1(l):
... l.extend([1])
... return l
...
>>> def f2(l):
... l += [1]
... return l
...
>>> impo
Steven Bethard wrote:
(1) I didn't see the top of this thread, but I'm assuming that you've
got a conditional or something in your real loop or you could just use
lst.extend(items) without ever iterating over the items list. Your real
code may actually require extend-style functionality, but as
Ishwor wrote:
Could u run the code in your machine and perhaps and let me know what
the average speed is??
The code is -
[snip code not using timeit]
Are you aware of the timeit module? It can do most of these timings for
you. Here's the code I used:
-- extend.py ---
On Sun, 26 Dec 2004 18:37:35 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote:
>
> "Ishwor" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > On Sun, 26 Dec 2004 04:57:17 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote:
> >>
> >> "Ishwor" <[EMAIL PROTECTED]> wrote in message
> >> news:[E
"Ishwor" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Sun, 26 Dec 2004 04:57:17 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote:
>>
>> "Ishwor" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> > Hi all
>> > I have just wrote a small script to compare the speed of
On Sun, 26 Dec 2004 04:57:17 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote:
>
> "Ishwor" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi all
> > I have just wrote a small script to compare the speed of list addition
> > methods.
>
> There are two meanings of 'list addition':
>
"Ishwor" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all
> I have just wrote a small script to compare the speed of list addition
> methods.
There are two meanings of 'list addition':
li = li+[item] *copies* the list and adds item
li += [item] is the same as li.extend([it
Hi all
I have just wrote a small script to compare the speed of list addition methods.
heres what it looks like.
#listadditioncompare.py
#compare the speeds of 3 different type of list element addition
import time
def method(TYPE):
l1 = [];
l2 = [];
l3 = [];
if TYPE == 1:
10 matches
Mail list logo