[Tutor] PYTHONHASHSEED, -R

Albert-Jan Roskam fomcl at yahoo.com
Sat Jul 27 21:19:59 CEST 2013


Hi,

In the little script below, are k and v guaranteed to be equal? 

# Python 2.7.3 (default, Sep 26 2012, 21:53:58)  [GCC 4.7.2] on linux2
# rnd.py

d = {i : i for i in range(50)}
k, v  = d.keys(), d.values()
assert k == v, "keys and values not the same"

I tried: 
python -R rnd.py

(-R means Turn on hash randomization, see http://docs.python.org/2.7/using/cmdline.html)
This does not raise an AssertionError, so it appears that they are indeed guranteed to be the same in CPython.

Regards,
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a 
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 


More information about the Tutor mailing list