PYTHONHASHSEED VALUE

David Raymond David.Raymond at tomtom.com
Tue May 14 12:57:01 EDT 2019


What is the test case actually checking for, and why?

One of the main aspects of a set is that it's unordered. So something checking to make sure the order of an unordered object is some static value seems like it's testing for the wrong thing.


-----Original Message-----
From: Python-list [mailto:python-list-bounces+david.raymond=tomtom.com at python.org] On Behalf Of Rishabh Mishra
Sent: Tuesday, May 14, 2019 5:47 AM
To: python-list at python.org
Subject: PYTHONHASHSEED VALUE

Dear Sir/Ma'am,

I was upgrading a codebase from python2 to python3. The testcases fail in
python3 code because the set() function produces a different order from
python2.

e.g. set in py2 ={"it","is","rishabh","Mishra"}

Here in python 2.7 the PYTHONHASHSEED is disabled.

in py3 set ={"rishabh","it","is","mishra"}

I want the order to stay consistent with python2.7 to pass the test cases.

In python 3.3 above PYTHONHASHSEED=0 disbales the random shuffling but it
doesn't yield the same order as 2.7

So can you tell me for what value of PYTHONHASHSEED the order will stay
consistent?

Thank-You!

Yours sincerely,
Rishabh Mishra
-- 
https://mail.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list