Message381767
> 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. |
|
Date |
User |
Action |
Args |
2020-11-24 18:23:24 | BTaskaya | set | recipients:
+ BTaskaya, rhettinger, mark.dickinson, christian.heimes, Mark.Shannon, serhiy.storchaka, pablogsal |
2020-11-24 18:23:24 | BTaskaya | set | messageid: <1606242204.84.0.416447558206.issue42454@roundup.psfhosted.org> |
2020-11-24 18:23:24 | BTaskaya | link | issue42454 messages |
2020-11-24 18:23:24 | BTaskaya | create | |
|