jeudi 4 août 2016

Faster way to generate big strings

I want to generate a random string (containing letters and numbers, both upper and lower case). Usually, I'm using the below command:

''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(size))

However, this time I would like to generate a string which size is of several MB (for example 10 MB). Is this method good for doing this? My main concern is if this will not take to much time and if made there is a faster way to generate long string?




Aucun commentaire:

Enregistrer un commentaire