File Read/Write test program
andy
andy at eastonwest.co.uk
Thu Jan 9 18:31:52 EST 2003
On Wednesday 08 Jan 2003 2:11 am, Manuel M. Garcia wrote:
> meg = "*" * (1048576 * 20)
>
> gives you a string of length 1048576 * 20 in one step
>
> Manuel
>
> On Tue, 7 Jan 2003 20:11:33 +0000, andy <andy at eastonwest.co.uk> wrote:
> (edit)
>
> >def generate_chunk(megabytes):
> > """ returns a string containing megabytes*1048576 asterisks """
> > meg="*"
> > for n in range(20):
> > meg=meg+meg
> > chunk=""
> > for n in range(megabytes):
> > chunk=chunk+meg
> > return chunk
thanx mate. I just knew there must be a better way to do it, but couldn't
figure out where to start looking.
Looks neater, and more intuitive.
As I expected, without all that heavy-duty memory copying, it's SIGNIFICANTLY
faster too.
:-)
The first thing I noticed about Python is that it was really easy to learn.
The second thing I noticed is that there's just *SO* *MUCH* to learn!
regards,
-andyj
More information about the Python-list
mailing list