samedi 25 mai 2019

Are seeded random numbers not consistent between python versions?

Question:

Why are seeded random outputs seemingly different across python versions? Have I missed something obvious, is it a documented behavior (I could not find it)

Observed results:

An attempt to reproduce seeded random numbers across python versions produces different results:

# python 3.7
rachel = sorted(Random('rachel').sample(range(57), 6))
larry = sorted(Random('larry').sample(range(57), 6))
armin = sorted(Random('armin').sample(range(57), 6))
laura = sorted(Random('laura').sample(range(57), 6))
rachel, larry, armin, laura

output:

([8, 22, 27, 35, 45, 47],
 [10, 18, 20, 29, 45, 47],
 [4, 7, 15, 22, 47, 52],
 [5, 8, 37, 40, 50, 55])

Comparison point:

Whereas a screenshot from Raymond Hettinger's advanced python at Europycon 2011 is showing a different output - probably python 2.6 or 2.7: (the image quality is poor, but the results are clearly different)

enter image description here




Aucun commentaire:

Enregistrer un commentaire