Message381767
| Author |
BTaskaya |
| Recipients |
BTaskaya, Mark.Shannon, christian.heimes, mark.dickinson, pablogsal, rhettinger, serhiy.storchaka |
| Date |
2020年11月24日.18:23:24 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1606242204.84.0.416447558206.issue42454@roundup.psfhosted.org> |
| In-reply-to |
| Content |
> I'm slightly concerned about hashability of slice objects. Currently the slice constructor does not ensure that any slice parameter is a number. You can do horrible stuff like this:
The same thing can be applied to tuples, which are hashable if all the items are hashable. Since the underlying slice hash uses a tuple of start, stop, step I think we are safe on that.
>>> hash((None, {}, None))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'
>>> hash(slice(None, {}, None))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'
Also I limited the scope of the optimization only for integers, so the folded slices can only have arguments as either integers or Nones. |
|