MCPcopy Index your code
hub / github.com/RustPython/RustPython / _to_memoryview

Function _to_memoryview

Lib/test/test_io.py:4099–4105  ·  view source on GitHub ↗

Convert bytes-object *buf* to a non-trivial memoryview

(buf)

Source from the content-addressed store, hash-verified

4097 return _to_memoryview(super().read(len_))
4098
4099def _to_memoryview(buf):
4100 '''Convert bytes-object *buf* to a non-trivial memoryview'''
4101
4102 arr = array.array('i')
4103 idx = len(buf) - len(buf) % arr.itemsize
4104 arr.frombytes(buf[:idx])
4105 return memoryview(arr)
4106
4107
4108class CTextIOWrapperTest(TextIOWrapperTest):

Callers 3

test_read_byteslikeMethod · 0.85
read1Method · 0.85
readMethod · 0.85

Calls 2

lenFunction · 0.85
frombytesMethod · 0.80

Tested by

no test coverage detected