Re: How to increase the speed of this program?



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

</F>

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 and start fiddling.

Anyone who could use this? Suggestions on name? Argument order?

Functionality: same as array.array(typecode, [repeat_value]) *
repeat_count. So it would cope with array.filledarray('c', "foo", 10)

I'm presuming an additional constructor would be better than doubling
up on the existing one:

array.array(typecode[, initializer)
and
array.array(typecode[, repeat_value, repeat_count])

Cheers,
John

.



Relevant Pages

  • Re: Object Initializers
    ... the ContactManagerModel class in the Constructor Initializer, ... does the "new ContactManagerModel()" execute? ... ContactManagerModel class in the Object Initializer, ... Depends on what you mean by "object initializer". ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Object Initializers
    ... particular, what is the difference between instantiating the ContactManagerModel class in the Object Initializer, as opposed to instantiating it in the constructor body? ... public ContactController(): this) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: scalar member with missing initializer
    ... I just ran into a bug where a bool member had been added with no initializer. ... the member ended up with non-zero values but in release builds it started zero. ... (For members with constructors, one would expect the constructor to leave the object in a well-defined state. ...
    (microsoft.public.vc.language)
  • Re: Object initializer question
    ... through the program and it looks like the object initializer is ... the fact that you say that the "initializer is   ... I have created a user control ... initialised during the constructor is gone. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Object initializer question
    ... the view is a usercontrol. ... through the program and it looks like the object initializer is ... initialised during the constructor is gone. ...
    (microsoft.public.dotnet.languages.csharp)