[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-09 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- stage: -> resolved ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-09 Thread Radosław Szalski
Radosław Szalski added the comment: Thanks for the comments, you are both correct. I think that the issue is resolved now, so I'm closing this a won't fix. -- status: open -> closed ___ Python tracker

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Note that Decimal(0.05) != Decimal('0.05'). >>> Decimal(0.05) Decimal('0.05000277555756156289135105907917022705078125') >>> hash(Decimal(0.05)) 966367654 >>> hash(Decimal('0.05000277555756156289135105907917022705078125')) 966367654 >>>

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-09 Thread Mark Dickinson
Mark Dickinson added the comment: > the behavior differs simply based on whether the Decimal was created from a > string vs a float That's not quite right: a Decimal object keeps no knowledge of how it was created. The behaviour differs depending on whether the value of the Decimal happens to

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-09 Thread Radosław Szalski
Radosław Szalski added the comment: Thanks for the reply and analysis, Mark. My motivation was that as a "clueless user", I shouldn't worry about how Decimals are created. Given two equal numbers, I would expect their behavior (e.g., result of a hash) to be the same as well. In this example, t

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-08 Thread Mark Dickinson
Changes by Mark Dickinson : -- status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-08 Thread Mark Dickinson
Mark Dickinson added the comment: For what it's worth, here are timings on my machine showing the overhead of the extra equality check when a hash collision occurs. Python 2.7.11 (default, Mar 1 2016, 18:08:21) Type "copyright", "credits" or "license" for more information. IPython 4.2.0 -- A

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-08 Thread Mark Dickinson
Changes by Mark Dickinson : -- resolution: -> wont fix status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing li

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-08 Thread Mark Dickinson
Mark Dickinson added the comment: There's nothing wrong with two different Decimal objects having the same hash (indeed, it's inevitable, given that there are fewer than 2**64 hash values available, and many more possible Decimal objects). It only becomes a problem if you have a largish natura

[issue27265] Hash of different, specific Decimals created from str is the same

2016-06-08 Thread Radosław Szalski
New submission from Radosław Szalski: Python 2.7.11 (default, May 9 2016, 19:53:39) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from decimal import Decimal >>> hash(Decimal('0.05')) == hash(Decimal(