Batuhan Taskaya <[email protected]> added the comment:
> 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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42454>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com