[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-08 Thread Mark Dickinson
Mark Dickinson added the comment: Thanks, Francois. Indeed, comparing hashes isn't a good way to implement equality. :-) Closing here. -- stage: -> resolved status: open -> closed ___ Python tracker

[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-07 Thread Francois Schneider
Francois Schneider added the comment: Thanks for the analysis, I agree completely. Actually the problem was coming from my code where one of the __eq__ method was implemented like this: >>> def __eq__(self, other): >>> return hash(self) == hash(other) so 2 instances with only a slight

[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-07 Thread Mark Dickinson
Change by Mark Dickinson : -- resolution: -> not a bug status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing

[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-07 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-07 Thread Mark Dickinson
Mark Dickinson added the comment: > I'd propose hashing a tuple instead of using the xor. To be clear; I'd propose this _only_ if there's evidence that the current hashing scheme is unsatisfactory for real-world use-cases. Otherwise, on an "if it's not broken, don't fix it" basis, I don't

[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Concur with Mark. -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list

[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-07 Thread Mark Dickinson
Mark Dickinson added the comment: This shouldn't be a problem: there's no rule that says that different objects should have different hashes. Indeed, with a countable infinity of possible different hashable inputs, a deterministic hashing algorithm, and only finitely many outputs, such a

[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-06 Thread Francois Schneider
New submission from Francois Schneider : >>> import ipaddress >>> hash(ipaddress.ip_network(u'20.0.2.3/32')) == >>> hash(ipaddress.ip_network(u'20.0.2.0/30')) True -- components: Library (Lib) messages: 318835 nosy: Francois Schneider priority: normal severity: normal status: open

[issue33784] hash collision in instances of ipaddress.ip_network

2018-06-06 Thread Francois Schneider
Change by Francois Schneider : -- versions: +Python 3.4, Python 3.5 ___ Python tracker ___ ___ Python-bugs-list mailing list