This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients belopolsky, josh.r, meador.inge, pitrou, remi.lapeyre, scoder, serhiy.storchaka, yselivanov
Date 2019-05-07.14:19:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557238767.48.0.118246104923.issue11107@roundup.psfhosted.org>
In-reply-to
Content
Remi: The reason they're not hashable is presumably because it would make them valid dictionary keys, further confusing the difference between sequences and mappings. x[::-1] would, for a sequence, return a reversed sequence, but for a mapping, would end up using the slice as a key (not actually slicing) to obtain a single value. Confusing at best.

Serhiy: It was discussed on the other issue, but the rationale there was, to quote Raymond:

* too many other things need to be changed to support it
* the measured win is somewhat small
* we have a negative bias towards expanding the peephole optimizer
* the AST may be a better place to do these kind of optimizations

Of those, only the first bullet is (essentially) unchanged. Addressing the following points in order:

* The win will likely be higher given that the __getslice__ protocol no longer exists; where slice objects need not be constructed in many cases in Python 2 (which had the SLICE+N bytecodes to perform subscripting directly, without a separate code to build a slice), leaving only slices with a step dependent on actually building slices. Nowadays, x[:-1] requires building a slice object, as does x[1:] and the like, where previously they did not
* The approach I'm taking does not use the peephole optimizer in any way
* I'm making the changes in the AST optimizer

Perhaps the issues with "too many other things need to be changed" remain, but I'd like to at least have a PR in place so that, should the marshalling format change be accepted, we'd be able to take advantage of it.

Side-note: The marshal code for marshalling slices that I chose was ':'; seemed rather appropriate for slices, and conveniently, it was not already in use. :-)
History
Date User Action Args
2019-05-07 14:19:27josh.rsetrecipients: + josh.r, belopolsky, pitrou, scoder, meador.inge, serhiy.storchaka, yselivanov, remi.lapeyre
2019-05-07 14:19:27josh.rsetmessageid: <1557238767.48.0.118246104923.issue11107@roundup.psfhosted.org>
2019-05-07 14:19:27josh.rlinkissue11107 messages
2019-05-07 14:19:27josh.rcreate