Re: How to increase the speed of this program?

2006-11-28 Thread Klaas
Klaas wrote: > Klaas wrote: > > > In fact, you can make it about 4x faster by balancing: > > > > [EMAIL PROTECTED] ~]$ python -m timeit -s "from array import array" > > "array('c','\0'*200)*500" > > 1 loops, best of 3: 32.4 usec per loop > > This is an unclean minimally-tested patch which achi

Re: How to increase the speed of this program?

2006-11-28 Thread Klaas
Klaas wrote: > In fact, you can make it about 4x faster by balancing: > > [EMAIL PROTECTED] ~]$ python -m timeit -s "from array import array" > "array('c','\0'*200)*500" > 1 loops, best of 3: 32.4 usec per loop This is an unclean minimally-tested patch which achieves reasonable performance (

Re: How to increase the speed of this program?

2006-11-28 Thread Klaas
John Machin wrote: > Thanks, that's indeed faster than array(t, [v]*n) but what I had in > mind was something like an additional constructor: > > array.filledarray(typecode, repeat_value, repeat_count) > > which I speculate should be even faster. Looks like I'd better get a > copy of arraymodule.c

Re: How to increase the speed of this program?

2006-11-28 Thread Fredrik Lundh
John Machin wrote: > Thanks, that's indeed faster than array(t, [v]*n) but what I had in > mind was something like an additional constructor: > > array.filledarray(typecode, repeat_value, repeat_count) > > which I speculate should be even faster. before you add a new API, you should probably st

Re: How to increase the speed of this program?

2006-11-28 Thread John Machin
Fredrik Lundh wrote: > John Machin wrote: > > > I'm extremely agnostic about the spelling :-) IOW I'd be very glad of > > any way [pure Python; e.g. maintaining my own version of the array > > module doesn't qualify] to simply and rapidly create an array.array > > instance with typecode t and numbe

Re: How to increase the speed of this program?

2006-11-28 Thread Peter Otten
Fredrik Lundh wrote: > John Machin wrote: > >> I'm extremely agnostic about the spelling :-) IOW I'd be very glad of >> any way [pure Python; e.g. maintaining my own version of the array >> module doesn't qualify] to simply and rapidly create an array.array >> instance with typecode t and number

Re: How to increase the speed of this program?

2006-11-28 Thread Fredrik Lundh
John Machin wrote: > I'm extremely agnostic about the spelling :-) IOW I'd be very glad of > any way [pure Python; e.g. maintaining my own version of the array > module doesn't qualify] to simply and rapidly create an array.array > instance with typecode t and number of elements n with each elemen

Re: How to increase the speed of this program?

2006-11-28 Thread John Machin
Peter Otten wrote: > Peter Otten wrote: > > > Leo Kislov wrote: > > > >> > >> Peter Otten wrote: > >>> Peter Otten wrote: > >>> > >>> > HYRY wrote: > >>> > > >>> >> I want to join two mono wave file to a stereo wave file by only using > >>> >> the default python module. > >>> >> Here is my program

Re: How to increase the speed of this program?

2006-11-28 Thread Leo Kislov
HYRY wrote: > Peter Otten wrote: > > HYRY wrote: > > > > > I want to join two mono wave file to a stereo wave file by only using > > > the default python module. > > > Here is my program, but it is much slower than the C version, so how > > > can I increase the speed? > > > I think the problem is a

Re: How to increase the speed of this program?

2006-11-28 Thread Peter Otten
Peter Otten wrote: > Leo Kislov wrote: > >> >> Peter Otten wrote: >>> Peter Otten wrote: >>> >>> > HYRY wrote: >>> > >>> >> I want to join two mono wave file to a stereo wave file by only using >>> >> the default python module. >>> >> Here is my program, but it is much slower than the C version,

Re: How to increase the speed of this program?

2006-11-28 Thread Peter Otten
Leo Kislov wrote: > > Peter Otten wrote: >> Peter Otten wrote: >> >> > HYRY wrote: >> > >> >> I want to join two mono wave file to a stereo wave file by only using >> >> the default python module. >> >> Here is my program, but it is much slower than the C version, so how >> >> can I increase the

Re: How to increase the speed of this program?

2006-11-28 Thread Leo Kislov
Peter Otten wrote: > Peter Otten wrote: > > > HYRY wrote: > > > >> I want to join two mono wave file to a stereo wave file by only using > >> the default python module. > >> Here is my program, but it is much slower than the C version, so how > >> can I increase the speed? > >> I think the problem

Re: How to increase the speed of this program?

2006-11-28 Thread Peter Otten
Peter Otten wrote: > HYRY wrote: > >> I want to join two mono wave file to a stereo wave file by only using >> the default python module. >> Here is my program, but it is much slower than the C version, so how >> can I increase the speed? >> I think the problem is at line #1, #2, #3. > >> oarray

Re: How to increase the speed of this program?

2006-11-28 Thread HYRY
Peter Otten wrote: > HYRY wrote: > > > I want to join two mono wave file to a stereo wave file by only using > > the default python module. > > Here is my program, but it is much slower than the C version, so how > > can I increase the speed? > > I think the problem is at line #1, #2, #3. > > > oa

Re: How to increase the speed of this program?

2006-11-28 Thread HYRY
I think oarray = array.array("h", [0]*(len(larray)+len(rarray))) #1 oarray[0::2] = larray#2 oarray[1::2] = rarray#3 will be executed at C level, but if I use itertools, the program is executed at Python level. So the itertools

Re: How to increase the speed of this program?

2006-11-28 Thread Peter Otten
HYRY wrote: > I want to join two mono wave file to a stereo wave file by only using > the default python module. > Here is my program, but it is much slower than the C version, so how > can I increase the speed? > I think the problem is at line #1, #2, #3. > oarray = array.array("h", [0]*(len(lar

Re: How to increase the speed of this program?

2006-11-28 Thread Peter Otten
HYRY wrote: > I want to join two mono wave file to a stereo wave file by only using > the default python module. > Here is my program, but it is much slower than the C version, so how > can I increase the speed? > I think the problem is at line #1, #2, #3. > oarray = array.array("h", [0]*(len(lar

Re: How to increase the speed of this program?

2006-11-28 Thread Paul McGuire
"HYRY" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I want to join two mono wave file to a stereo wave file by only using > the default python module. > Here is my program, but it is much slower than the C version, so how > can I increase the speed? > I think the problem is at line

How to increase the speed of this program?

2006-11-27 Thread HYRY
I want to join two mono wave file to a stereo wave file by only using the default python module. Here is my program, but it is much slower than the C version, so how can I increase the speed? I think the problem is at line #1, #2, #3. import wave import array lfile = wave.open(lfilename) rfile = w