Message208726
While poking around at bytes() related things, I noticed that the
tp_richcompare method for bytes does not use the tp_as_buffer
interface. Making it use it is quite easy, probably even makes the
code simpler and faster.
However, using it would mean that you could compare by bytes() and
bytearray() to any object that implemented tp_as_buffer. I'm not
sure about the whole implications of that.
I tried changing it and found that a test failed for memoryview.
The unit test expects TypeError from memoryview if you try to order
them, e.g.
>>> memoryview(b'a') < b'b'
...
TypeError: unorderable types: memoryview() > bytes()
>>> memoryview(b'a') < memoryview(b'b')
...
TypeError: unorderable types: memoryview() > memoryview()
That's inconsistent though, since bytearray does use tp_as_buffer:
>>> memoryview(b'a') < bytearray(b'b')
True
I think we should make bytes() use tp_as_buffer. Attached is a patch that
implements the idea. Needs some thought and review yet. |
|
Date |
User |
Action |
Args |
2014-01-22 00:40:29 | nascheme | set | recipients:
+ nascheme |
2014-01-22 00:40:29 | nascheme | set | messageid: <1390351229.22.0.995411790956.issue20339@psf.upfronthosting.co.za> |
2014-01-22 00:40:29 | nascheme | link | issue20339 messages |
2014-01-22 00:40:29 | nascheme | create | |
|