File Read/Write test program

Bengt Richter bokr at oz.net
Fri Jan 10 10:51:20 EST 2003


On Fri, 10 Jan 2003 08:40:32 GMT, "Fredrik Lundh" <fredrik at pythonware.com> wrote:

>Manuel M. Garcia wrote:
>
>> meg = "*" * (1048576 * 20)
>>
>> gives you a string of length 1048576 * 20 in one step
>
>interestingly enough,
>
>    meg = "*" * 1048576 * 20
>
>gives you the same result in much less time.
>
Assuming a string multiply translates to allocating
sufficient output space and repetively calling a
machine language memory move routine (and that single-byte
source strings are not special cased, which would change results),
then, one way presumably does 20M 1-byte-block moves vs
1M 1-byte block moves + 20 * 1M-byte-block moves
so I assume the percentage setup overhead for
1-byte moves is the killer.

Think special-casing single-byte string muliplies is worth while?
It would be as fast as memory bandwidth would allow.

Regards,
Bengt Richter




More information about the Python-list mailing list