Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:

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. :-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue11107>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to