Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5866

Re: hash values and equality

References (7 earlier) <mailman.1822.1305870290.9059.python-list@python.org> <0deha8-6u9.ln1@satorlaser.homedns.org> <4DD68DAA.9050209@mrabarnett.plus.com> <BANLkTin7E_xsoe5UtGHquHGjkcy82fAOJw@mail.gmail.com> <BANLkTimXgEsyco6tDZhiPf_MLY9EQOADxw@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2011-05-20 11:59 -0600
Subject Re: hash values and equality
Newsgroups comp.lang.python
Message-ID <mailman.1848.1305914416.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, May 20, 2011 at 10:36 AM, Chris Kaynor <ckaynor@zindagigames.com> wrote:
> I think the question was: can this dummy code ever produce a set containing
> less then itemCount items (for 0 < itemCount < 2**32)?

In CPython, no.  Even when you get a hash collision, the code checks
to see whether the hashes are actually equal before it calls the rich
comparison, the former check being a much faster operation since the
hash values are cached.

I'm not sure whether this can be counted on for all Python
implementations, though.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

hash values and equality Ethan Furman <ethan@stoneleaf.us> - 2011-05-19 22:43 -0700
  Re: hash values and equality Peter Otten <__peter__@web.de> - 2011-05-20 08:38 +0200
    Re: hash values and equality Ethan Furman <ethan@stoneleaf.us> - 2011-05-20 10:57 -0700
    Re: hash values and equality Peter Otten <__peter__@web.de> - 2011-05-20 22:25 +0200
    Re: hash values and equality Ethan Furman <ethan@stoneleaf.us> - 2011-05-20 14:48 -0700
  Re: hash values and equality Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-05-20 08:33 +0200
    Re: hash values and equality MRAB <python@mrabarnett.plus.com> - 2011-05-20 16:50 +0100
    Re: hash values and equality Chris Angelico <rosuav@gmail.com> - 2011-05-21 02:20 +1000
    Re: hash values and equality Ian Kelly <ian.g.kelly@gmail.com> - 2011-05-20 11:59 -0600
    Re: hash values and equality Ethan Furman <ethan@stoneleaf.us> - 2011-05-20 11:38 -0700
      Re: hash values and equality Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-05-21 20:24 +1200
        Re: hash values and equality Peter Otten <__peter__@web.de> - 2011-05-21 11:24 +0200
    Re: hash values and equality Christian Heimes <lists@cheimes.de> - 2011-05-20 21:01 +0200
    Re: hash values and equality MRAB <python@mrabarnett.plus.com> - 2011-05-20 21:17 +0100
      Re: hash values and equality Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-21 00:47 +0000
        Re: hash values and equality MRAB <python@mrabarnett.plus.com> - 2011-05-21 02:02 +0100
          Re: hash values and equality Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-21 01:55 +0000
    Re: hash values and equality John Nagle <nagle@animats.com> - 2011-05-21 15:55 -0700
      Re: hash values and equality Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2011-05-22 01:07 +0200
      Re: hash values and equality Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-22 00:24 +0000

csiph-web