• Kirill Smelkov's avatar
    golang_str: Teach b/u to accept objects with buffer interface · d7e55bb0
    Kirill Smelkov authored
    And to convert them to bstr/ustr decoding buffer data as if it was
    bytes. This is needed if e.g. we have data in mmap or numpy.ndarray, and
    want to convert the data to string. The conversion is always explicit via
    explicit call to b/u. And for bstr/ustr constructors, we preserver their
    behaviour to match unicode constructor not to convert automatically, but
    instead to stringify the object, e.g. as shown below:
    
        In [1]: bdata = b'hello 123'
    
        In [2]: mview = memoryview(bdata)
    
        In [3]: str(mview)
        Out[3]: '<memory at 0x7fb226b26700>'	# NOTE _not_ b'hello 123'
    d7e55bb0
_golang_str.pyx 25.2 KB