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 nascheme
Recipients nascheme
Date 2014-01-22.00:40:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390351229.22.0.995411790956.issue20339@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-01-22 00:40:29naschemesetrecipients: + nascheme
2014-01-22 00:40:29naschemesetmessageid: <1390351229.22.0.995411790956.issue20339@psf.upfronthosting.co.za>
2014-01-22 00:40:29naschemelinkissue20339 messages
2014-01-22 00:40:29naschemecreate