Issue 40603: slice not hashable - Python tracker

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Will Bradshaw, isdanni, remi.lapeyre, rhettinger, steven.daprano
Priority: normal Keywords: easy (C)

Created on 2020-05-12 01:23 by Will Bradshaw, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
patches.zip Will Bradshaw, 2020-05-12 01:23 patch to add slicing functionality to slices
Messages (5)
msg368693 - (view) Author: Will Bradshaw (Will Bradshaw) Date: 2020-05-12 01:23
slice cannot be hashed which make some operations significantly more annoying. see https://groups.google.com/forum/#!topic/comp.lang.python/SvhkWwSDeIw
msg368694 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-05-12 01:41
Please re-upload the patch file as an uncompressed text file, as it is quite difficult for many people to view zip files in their browser.
msg368696 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-05-12 02:25
This is a reasonable use case.

+1 for making slice() hashable.

Will, you're welcome to submit a PR.  If not, I'm sure someone else would be happy to scoop this up :-)
msg368700 - (view) Author: Danni (isdanni) * Date: 2020-05-12 03:32
Would be happy to help with this. Sent a PR soon ;)
msg368708 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2020-05-12 08:34
I think slices were explicitly made not hashable to avoid issues to avoid issues with dictionaries, see discussion at https://mail.python.org/pipermail/python-list/2001-March/076101.html and issue 408326.

The commit that did this is https://github.com/python/cpython/commit/a1351fbd884189329bbcb6c688ca992fc1afc3f6

Is this not needed anymore? Wouldn't this need to be discussed on python-ideas?