Hash of integers for use in Random module

W

Will McGugan

Hi,

If I retrieve the hash of an integer, will it always return the same
value across platforms?

This reason I ask is that I want to produce a sequence of pseudo random
numbers using the random module, that I can re-create later on. So I'll
need to store the seed value, but Random.seed takes a hashable object
rather than an integer directly.

Which brings another question to mind. Are hashes of builtin objects in
general consistent across platforms, or are they an implementation
detail that could change?

TIA,

Will McGugan
 
W

Will McGugan

Will said:
Hi,

If I retrieve the hash of an integer, will it always return the same
value across platforms?

This reason I ask is that I want to produce a sequence of pseudo random
numbers using the random module, that I can re-create later on. So I'll
need to store the seed value, but Random.seed takes a hashable object
rather than an integer directly.

Which brings another question to mind. Are hashes of builtin objects in
general consistent across platforms, or are they an implementation
detail that could change?

*sigh* Didnt read the docs closely enough. It does say that ints and
longs are used directly..

Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,222
Messages
2,571,138
Members
47,755
Latest member
Grazynkaa

Latest Threads

Top