Re: How to increase the speed of this program?
- From: Peter Otten <__peter__@xxxxxx>
- Date: Tue, 28 Nov 2006 13:46:50 +0100
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 of elements n with each element
initialised to value v (default to be the zero appropriate to the
typecode).
array(t, [v])*n
Of course Leo was already there before I messed it up again.
$ python2.5 -m timeit -s'from array import array; s = "abc"' 'a = array("c",
s); a*1000000'
10 loops, best of 3: 53.5 msec per loop
$ python2.5 -m timeit -s'from array import array; s = "abc"' 'a = array("c",
s); s*1000000'
100 loops, best of 3: 7.63 msec per loop
So str * N is significantly faster than array * N even if the same amount of
data is copied.
Peter
.
- References:
- How to increase the speed of this program?
- From: HYRY
- Re: How to increase the speed of this program?
- From: Leo Kislov
- Re: How to increase the speed of this program?
- From: Peter Otten
- Re: How to increase the speed of this program?
- From: Peter Otten
- Re: How to increase the speed of this program?
- From: John Machin
- Re: How to increase the speed of this program?
- From: Fredrik Lundh
- How to increase the speed of this program?
- Prev by Date: Re: Accessing file metadata on windows XP
- Next by Date: Re: Accessing file metadata on windows XP
- Previous by thread: Re: How to increase the speed of this program?
- Next by thread: Re: How to increase the speed of this program?
- Index(es):
Relevant Pages
|