xrange not hashable - why not?

Andrew MacIntyre andymac at bullseye.apana.org.au
Sun Jan 25 19:50:59 EST 2004


On Mon, 26 Jan 2004, Andrew MacIntyre wrote:

> On Sun, 25 Jan 2004, Gerrit Holl wrote:
>
> > why is an xrange object not hashable?
>
> xrange() returns an iterator.  iterators seem universally unhashable,
> probably because they can't be deemed "concrete", though I can't find
> anything in the 2.3.3 docs about this - perhaps the relevant PEPs might.

Hmmm... part fact, part BS on my part.

Prior to 2.3, xrange() returned an object that implemented lazy item
access, which didn't have explicit hash support.

With 2.3, xrange() began returning an iterator, which is hashable (as
others have pointed out).

--
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac at pcug.org.au             (alt) |        Belconnen  ACT  2616
Web:    http://www.andymac.org/               |        Australia




More information about the Python-list mailing list