[issue7889] random produces different output on different architectures

2010-09-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: Fixed in r84574 and r84576. The seed function no longer uses hash() for str, bytes, or bytearray arguments. -- resolution: -> fixed status: open -> closed ___ Python tracker

[issue7889] random produces different output on different architectures

2010-02-09 Thread Terrence Cole
Terrence Cole added the comment: Thank you for all the help! I'm glad to see that the use of hash() on buffer compatible objects is an actual gotcha and not just me being obtuse. Also, for those googling who, like me, won't be able to use 3.2's from_bytes until 3.2 is released in December, h

[issue7889] random produces different output on different architectures

2010-02-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: I will update the documentation. -- components: +Documentation -Library (Lib) versions: -Python 2.6, Python 2.7, Python 3.2 ___ Python tracker _

[issue7889] random produces different output on different architectures

2010-02-09 Thread Mark Dickinson
Mark Dickinson added the comment: [Antoine] > >>> random.seed(int.from_bytes(b'foo', 'little')) +1 for either documenting this useful trick, or modifying init_by_array to do this automatically for buffer-like objects. Disallowing other types of input for the seed sounds dangerous, though. --

[issue7889] random produces different output on different architectures

2010-02-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: Well, ideally we should drop the automatic hash() and only accept: 1) ints/longs 2) buffer-like objects (and tell people to hash() explicitly if they want to) If that's too disruptive, we should document it. And, for 3.x, provide the following recipe to hash f

[issue7889] random produces different output on different architectures

2010-02-09 Thread Michael Foord
Michael Foord added the comment: If we aren't going to fix it, should we document the limitation? -- nosy: +michael.foord ___ Python tracker ___ _

[issue7889] random produces different output on different architectures

2010-02-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, it's simple really. When seeding from something else than an integer, seed() takes the hash of the object (instead of considering all its bytes, which might be considered a weakness since you lose entropy -- also, Python hash() is not supposed to be crypt

[issue7889] random produces different output on different architectures

2010-02-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: It works when seeding from a single integer, though: >>> import random >>> random.seed(123) >>> random.random() 0.052363598850944326 So I guess it's the seeding-from-an-array which is buggy. -- ___ Python tracker <

[issue7889] random produces different output on different architectures

2010-02-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: It's not only getrandbits(): ** x86 ** >>> random.seed(b'foo') >>> random.random() 0.95824312997798622 ** x86_64 ** >>> random.seed(b'foo') >>> random.random() 0.88694660946819537 -- nosy: +pitrou ___ Python tracke

[issue7889] random produces different output on different architectures

2010-02-09 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue7889] random produces different output on different architectures

2010-02-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: Hmm, this may be difficult to fix without breaking somebody's expectation of repeating sequences they've already generated. The code is in random_getrandbits(): http://svn.python.org/view/python/trunk/Modules/_randommodule.c?revision=72344&view=markup ---

[issue7889] random produces different output on different architectures

2010-02-08 Thread Martin v . Löwis
Martin v. Löwis added the comment: Would you like to work on a patch? -- nosy: +loewis ___ Python tracker ___ ___ Python-bugs-list mai

[issue7889] random produces different output on different architectures

2010-02-08 Thread Terrence Cole
New submission from Terrence Cole : This code: >>> random.seed(b'foo') >>> random.getrandbits(8) ...repeated 7 more times... Yields the sequence of values: amd64: 227, 199, 34, 218, 83, 115, 236, 254 x86: 245, 198, 204, 66, 219, 4, 168, 93 Comments in the source seem to indicate random