[issue42454] Move slice creation to the compiler for constants

Josh Rosenberg report at bugs.python.org
Wed Nov 25 00:04:34 EST 2020


Josh Rosenberg <shadowranger+python at gmail.com> added the comment:

There is an open issue for this already, under #11107 (a reopen of the closed #2268, where the reopen was justified due to Python 3 making slice objects more common), just so you know.

I made a stab at this a while ago and gave up due to the problems with making slices constants while trying to keep them unhashable (and I never got to handling the marshal format updates properly). It doesn't seem right to incidentally make:

    something[::-1] = something

actually work, and be completely nonsensical, when "something" happens to be a dict, when previously, you'd get a clear TypeError for trying to do it. I could definitely see code using duck-typing via slices to distinguish sequences from other iterables and mappings, and making mapping suddenly support slices in a nonsensical way is... odd.

----------
nosy: +josh.r

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42454>
_______________________________________


More information about the Python-bugs-list mailing list