[Python-ideas] Why aren't slices hashable?

Michael Selik michael.selik at gmail.com
Sat Jun 18 13:11:24 EDT 2016


On Sat, Jun 18, 2016 at 12:51 PM Ed Minnix <egregius313 at gmail.com> wrote:

> I was experimenting in the repl and I noticed something odd: slices are
> not hashable. I was wondering why this would be since, I would think slices
> are immutable, and most immutable objects are hashable.
>

Apparently that was to avoid mistakes. Otherwise there would be a bit of
confusion between assigning to a slice as the key or changing many keys.

https://bugs.python.org/issue408326
http://stackoverflow.com/questions/29980786/why-are-slice-objects-not-hashable-in-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160618/9d65bbf5/attachment.html>


More information about the Python-ideas mailing list