MCPcopy Create free account
hub / github.com/apache/arrow / ParseBinary

Method ParseBinary

python/pyarrow/src/arrow/python/common.h:399–420  ·  view source on GitHub ↗

View the given Python object as binary-like, i.e. bytes

Source from the content-addressed store, hash-verified

397
398 // View the given Python object as binary-like, i.e. bytes
399 Status ParseBinary(PyObject* obj) {
400 if (PyBytes_Check(obj)) {
401 bytes = PyBytes_AS_STRING(obj);
402 size = PyBytes_GET_SIZE(obj);
403 is_utf8 = false;
404 } else if (PyByteArray_Check(obj)) {
405 bytes = PyByteArray_AS_STRING(obj);
406 size = PyByteArray_GET_SIZE(obj);
407 is_utf8 = false;
408 } else if (PyMemoryView_Check(obj)) {
409 PyObject* ref = PyMemoryView_GetContiguous(obj, PyBUF_READ, 'C');
410 RETURN_IF_PYERROR();
411 Py_buffer* buffer = PyMemoryView_GET_BUFFER(ref);
412 bytes = reinterpret_cast<const char*>(buffer->buf);
413 size = buffer->len;
414 is_utf8 = false;
415 } else {
416 return Status::TypeError("Expected bytes, got a '", Py_TYPE(obj)->tp_name,
417 "' object");
418 }
419 return Status::OK();
420 }
421
422 // Parse bytes from a uuid.UUID object (stores reference to keep bytes alive)
423 Status ParseUuid(PyObject* obj) {

Callers 1

FromBinaryMethod · 0.95

Calls 2

TypeErrorFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected