def _nbytes(buf):
if isinstance(buf, memoryview):<EOL><INDENT>if PY3:<EOL><INDENT>return buf.nbytes<EOL><DEDENT>else:<EOL><INDENT>size = buf.itemsize<EOL>for dim in buf.shape:<EOL><INDENT>size *= dim<EOL><DEDENT>return size<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return len(buf)<EOL><DEDENT>
Return byte-size of a memoryview or buffer.