Re: How to increase the speed of this program?
- From: "Leo Kislov" <Leo.Kislov@xxxxxxxxx>
- Date: 28 Nov 2006 03:09:18 -0800
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 at line #1, #2, #3.
oarray = array.array("h", [0]*(len(larray)+len(rarray))) #1
ITEMSIZE = 2
size = ITEMSIZE*(len(larray) + len(rarray))
oarray = array.array("h")
oarray.fromstring("\0" * size)
may be a bit faster.
Peter
Thank you very much, that is just what I want.
Even faster: oarray = larray + rarray
C:\Python25>python -m timeit -s"from array import array; N = 10**6" "a
=array('h'); a.fromstring('\0'*(2*N))"
100 loops, best of 3: 9.57 msec per loop
C:\Python25>python -m timeit -s"from array import array; N = 10**6; b =
array('h', [0])*(N/2); c = b[:]" "a = b + c"
100 loops, best of 3: 5.7 msec per loop
-- Leo
.
- References:
- How to increase the speed of this program?
- From: HYRY
- How to increase the speed of this program?
- Prev by Date: RE: Accessing file metadata on windows XP
- Next by Date: Re: Modifying every alternate element of a sequence
- Previous by thread: Re: How to increase the speed of this program?
- Next by thread: Question about import and sys.path
- Index(es):
Relevant Pages
|