Re: Documentation of __hash__

2020-02-11 Thread Ethan Furman
On 02/11/2020 02:23 AM, klau...@gmail.com wrote: On Friday, February 7, 2020 at 4:30:23 PM UTC+1, Random832 wrote: The purpose of this rule is to save you from having to override the default __hash__ with something that will only raise an exception when you do not intend your class to be has

Re: Documentation of __hash__

2020-02-11 Thread klauck2
On Friday, February 7, 2020 at 4:30:23 PM UTC+1, Random832 wrote: > On Fri, Feb 7, 2020, at 10:14, Richard Damon wrote: > > On 2/6/20 2:13 PM, klau...@gmail.com wrote: > > > The default __eq__ method (object identity) is compatible with all > > > (reasonable) self-defined __hash__ method. > > > >

Re: Documentation of __hash__

2020-02-07 Thread Random832
On Fri, Feb 7, 2020, at 10:14, Richard Damon wrote: > On 2/6/20 2:13 PM, klau...@gmail.com wrote: > > The default __eq__ method (object identity) is compatible with all > > (reasonable) self-defined __hash__ method. > > > > Stefan > > If __eq__ compares just the id, then the only hash you need is

Re: Documentation of __hash__

2020-02-07 Thread Richard Damon
On 2/6/20 2:13 PM, klau...@gmail.com wrote: The default __eq__ method (object identity) is compatible with all (reasonable) self-defined __hash__ method. Stefan If __eq__ compares just the id, then the only hash you need is the default that is also the id. If you define a separate hash funct

Re: Documentation of __hash__

2020-02-06 Thread klauck2
The default __eq__ method (object identity) is compatible with all (reasonable) self-defined __hash__ method. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Documentation of __hash__

2020-02-05 Thread Christian Gollwitzer
Am 05.02.20 um 20:55 schrieb klau...@gmail.com: If not, why should a class not define __hash__, if it does not define __eq__? Hashes are not unique. When you insert or look up something in a hashtable, the hash is computed and used as the index into the table. Because the hash is not necessa

Re: Documentation of __hash__

2020-02-05 Thread klauck2
On Wednesday, February 5, 2020 at 7:41:13 PM UTC+1, Dieter Maurer wrote: > Stefan Halfpap wrote at 2020-2-5 14:57 +0100: > >I do not understand the following statement from the python (2 and 3) > >documentation regarding __hash__ and __eq__ methods: > >"If a class does not define an __eq__() > ><

Re: Documentation of __hash__

2020-02-05 Thread Dieter Maurer
Stefan Halfpap wrote at 2020-2-5 14:57 +0100: >I do not understand the following statement from the python (2 and 3) >documentation regarding __hash__ and __eq__ methods: >"If a class does not define an __eq__() > method it >shoul

Documentation of __hash__

2020-02-05 Thread Stefan Halfpap
Hi, I do not understand the following statement from the python (2 and 3) documentation regarding __hash__ and __eq__ methods: "If a class does not define an __eq__() method it should not define a __hash__()