New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
slice not hashable #84783
Comments
slice cannot be hashed which make some operations significantly more annoying. see https://groups.google.com/forum/#!topic/comp.lang.python/SvhkWwSDeIw |
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. |
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 :-) |
Would be happy to help with this. Sent a PR soon ;) |
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 bpo-408326. The commit that did this is a1351fb Is this not needed anymore? Wouldn't this need to be discussed on python-ideas? |
Guido, what are your thoughts on this proposal? On the one hand, the OP has a legitimate use case:
On the other hand, slice literals for mappings are a mixed bag, possibly useful in some cases, possibly surprising in others:
I like the idea of being able to cache array or sequence slices but worry about opening a can of worms for the general case. |
I think this is fine. The "danger" of d[a:b] seems overstated, it produces a clear KeyError. |
@gvanrossum Thanks for the looking at this. |
Note that this still needs a “what’s new” entry, since it is a new feature and might even trip some folks up (see the test changes needed). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: