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.
History
Date User Action Args
2020-11-24 18:23:24BTaskayasetrecipients: + BTaskaya, rhettinger, mark.dickinson, christian.heimes, Mark.Shannon, serhiy.storchaka, pablogsal
2020-11-24 18:23:24BTaskayasetmessageid: <1606242204.84.0.416447558206.issue42454@roundup.psfhosted.org>
2020-11-24 18:23:24BTaskayalinkissue42454 messages
2020-11-24 18:23:24BTaskayacreate