Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ configure_file("${PYARROW_CPP_SOURCE_DIR}/config_internal.h.cmake"

set(PYARROW_CPP_SRCS
${PYARROW_CPP_SOURCE_DIR}/arrow_to_pandas.cc
${PYARROW_CPP_SOURCE_DIR}/benchmark.cc
${PYARROW_CPP_SOURCE_DIR}/common.cc
${PYARROW_CPP_SOURCE_DIR}/config.cc
${PYARROW_CPP_SOURCE_DIR}/datetime.cc
Expand Down
45 changes: 0 additions & 45 deletions python/benchmarks/microbenchmarks.py

This file was deleted.

20 changes: 0 additions & 20 deletions python/pyarrow/benchmark.pxi

This file was deleted.

21 changes: 0 additions & 21 deletions python/pyarrow/benchmark.py

This file was deleted.

4 changes: 0 additions & 4 deletions python/pyarrow/includes/libarrow_python.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,6 @@ cdef extern from "arrow/python/extension_type.h" namespace "arrow::py":
CStatus UnregisterPyExtensionType(c_string type_name)


cdef extern from "arrow/python/benchmark.h" namespace "arrow::py::benchmark":
void Benchmark_PandasObjectIsNull(object lst) except *


cdef extern from "arrow/python/gdb.h" namespace "arrow::gdb" nogil:
void GdbTestSession "arrow::gdb::TestSession"()

Expand Down
10 changes: 5 additions & 5 deletions python/pyarrow/io.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ cdef class NativeFile(_Weakrefable):
# Allocate empty write space
obj = PyBytes_FromStringAndSizeNative(NULL, c_nbytes)

cdef uint8_t* buf = <uint8_t*> cp.PyBytes_AS_STRING(<object> obj)
cdef uint8_t* buf = <uint8_t*> cp.PyBytes_AsString(<object> obj)
with nogil:
bytes_read = GetResultValue(handle.get().Read(c_nbytes, buf))

Expand Down Expand Up @@ -488,7 +488,7 @@ cdef class NativeFile(_Weakrefable):
# Allocate empty write space
obj = PyBytes_FromStringAndSizeNative(NULL, c_nbytes)

cdef uint8_t* buf = <uint8_t*> cp.PyBytes_AS_STRING(<object> obj)
cdef uint8_t* buf = <uint8_t*> cp.PyBytes_AsString(<object> obj)
with nogil:
bytes_read = GetResultValue(handle.get().
ReadAt(c_offset, c_nbytes, buf))
Expand Down Expand Up @@ -1614,7 +1614,7 @@ cdef class Buffer(_Weakrefable):
if buffer.buf == NULL:
# ARROW-16048: Ensure we don't export a NULL address.
assert buffer.len == 0
buffer.buf = cp.PyBytes_AS_STRING(b"")
buffer.buf = cp.PyBytes_AsString(b"")
buffer.format = 'b'
buffer.internal = NULL
buffer.itemsize = 1
Expand Down Expand Up @@ -2643,7 +2643,7 @@ cdef class Codec(_Weakrefable):

if asbytes:
pyobj = PyBytes_FromStringAndSizeNative(NULL, max_output_size)
output_buffer = <uint8_t*> cp.PyBytes_AS_STRING(<object> pyobj)
output_buffer = <uint8_t*> cp.PyBytes_AsString(<object> pyobj)
else:
out_buf = allocate_buffer(
max_output_size, memory_pool=memory_pool, resizable=True
Expand Down Expand Up @@ -2705,7 +2705,7 @@ cdef class Codec(_Weakrefable):

if asbytes:
pybuf = cp.PyBytes_FromStringAndSize(NULL, output_size)
output_buffer = <uint8_t*> cp.PyBytes_AS_STRING(pybuf)
output_buffer = <uint8_t*> cp.PyBytes_AsString(pybuf)
else:
out_buf = allocate_buffer(output_size, memory_pool=memory_pool)
output_buffer = out_buf.buffer.get().mutable_data()
Expand Down
3 changes: 0 additions & 3 deletions python/pyarrow/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,5 @@ include "io.pxi"
# IPC / Messaging
include "ipc.pxi"

# Micro-benchmark routines
include "benchmark.pxi"

# Public API
include "public-api.pxi"
4 changes: 2 additions & 2 deletions python/pyarrow/src/arrow/python/arrow_to_pandas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,8 @@ Status ConvertMap(PandasOptions options, const ChunkedArray& data,
return CheckPyError();
},
[&list_item](int64_t idx, OwnedRef& key_value, OwnedRef& item_value) {
PyList_SET_ITEM(list_item.obj(), idx,
PyTuple_Pack(2, key_value.obj(), item_value.obj()));
PyList_SetItem(list_item.obj(), idx,
PyTuple_Pack(2, key_value.obj(), item_value.obj()));
return CheckPyError();
},
[&list_item] { return list_item.detach(); }, data, py_keys, py_items, item_arrays,
Expand Down
38 changes: 0 additions & 38 deletions python/pyarrow/src/arrow/python/benchmark.cc

This file was deleted.

36 changes: 0 additions & 36 deletions python/pyarrow/src/arrow/python/benchmark.h

This file was deleted.

24 changes: 15 additions & 9 deletions python/pyarrow/src/arrow/python/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
#include <utility>

#include "arrow/buffer.h"
#include "arrow/python/helpers.h"
#include "arrow/python/pyarrow.h"
#include "arrow/python/visibility.h"
#include "arrow/result.h"
#include "arrow/util/logging.h"
#include "arrow/util/macros.h"

namespace arrow {
Expand Down Expand Up @@ -398,12 +400,14 @@ struct PyBytesView {
// View the given Python object as binary-like, i.e. bytes
Status ParseBinary(PyObject* obj) {
if (PyBytes_Check(obj)) {
bytes = PyBytes_AS_STRING(obj);
size = PyBytes_GET_SIZE(obj);
bytes = PyBytes_AsString(obj);
size = PyBytes_Size(obj);
ARROW_DCHECK(!PyErr_Occurred());
is_utf8 = false;
} else if (PyByteArray_Check(obj)) {
bytes = PyByteArray_AS_STRING(obj);
size = PyByteArray_GET_SIZE(obj);
bytes = PyByteArray_AsString(obj);
size = PyByteArray_Size(obj);
ARROW_DCHECK(!PyErr_Occurred());
is_utf8 = false;
} else if (PyMemoryView_Check(obj)) {
PyObject* ref = PyMemoryView_GetContiguous(obj, PyBUF_READ, 'C');
Expand All @@ -413,8 +417,8 @@ struct PyBytesView {
size = buffer->len;
is_utf8 = false;
} else {
return Status::TypeError("Expected bytes, got a '", Py_TYPE(obj)->tp_name,
"' object");
return Status::TypeError("Expected bytes, got a '",
internal::PyObject_StdStringTypeName(obj), "' object");
}
return Status::OK();
}
Expand All @@ -425,10 +429,12 @@ struct PyBytesView {
RETURN_IF_PYERROR();
if (!PyBytes_Check(ref.obj())) {
return Status::TypeError("Expected uuid.UUID.bytes to return bytes, got '",
Py_TYPE(ref.obj())->tp_name, "' object");
internal::PyObject_StdStringTypeName(ref.obj()),
"' object");
}
bytes = PyBytes_AS_STRING(ref.obj());
size = PyBytes_GET_SIZE(ref.obj());
bytes = PyBytes_AsString(ref.obj());
size = PyBytes_Size(ref.obj());
ARROW_DCHECK(!PyErr_Occurred());
is_utf8 = false;
return Status::OK();
}
Expand Down
22 changes: 14 additions & 8 deletions python/pyarrow/src/arrow/python/datetime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ constexpr char* NonConst(const char* st) {
return const_cast<char*>(st);
}

static PyTypeObject MonthDayNanoTupleType = {};
static PyTypeObject* MonthDayNanoTupleType = nullptr;

static PyStructSequence_Field MonthDayNanoField[] = {
{NonConst("months"), NonConst("The number of months in the interval")},
Expand All @@ -67,8 +67,13 @@ static PyStructSequence_Field MonthDayNanoField[] = {
{nullptr, nullptr}};

static PyStructSequence_Desc MonthDayNanoTupleDesc = {
NonConst("MonthDayNano"),
NonConst("A calendar interval consisting of months, days and nanoseconds."),
NonConst("pyarrow.lib.MonthDayNano"),
NonConst("A calendar interval consisting of months, days and nanoseconds.\n"
"\n"
"Parameters\n"
"----------\n"
"iterable : sequence\n"
" The months, days and nanoseconds fields of the interval.\n"),
MonthDayNanoField,
/*n_in_sequence=*/3};

Expand Down Expand Up @@ -274,13 +279,14 @@ static inline Status PyDate_convert_int(int64_t val, const DateUnit unit, int64_
}

PyObject* NewMonthDayNanoTupleType() {
if (MonthDayNanoTupleType.tp_name == nullptr) {
if (PyStructSequence_InitType2(&MonthDayNanoTupleType, &MonthDayNanoTupleDesc) != 0) {
if (MonthDayNanoTupleType == nullptr) {
MonthDayNanoTupleType = PyStructSequence_NewType(&MonthDayNanoTupleDesc);
if (MonthDayNanoTupleType == nullptr) {
Py_FatalError("Could not initialize MonthDayNanoTuple");
}
}
Py_INCREF(&MonthDayNanoTupleType);
return (PyObject*)&MonthDayNanoTupleType;
Py_INCREF(MonthDayNanoTupleType);
return (PyObject*)MonthDayNanoTupleType;
}

Status PyTime_from_int(int64_t val, const TimeUnit::type unit, PyObject** out) {
Expand Down Expand Up @@ -596,7 +602,7 @@ Result<std::string> TzinfoToString(PyObject* tzinfo) {

PyObject* MonthDayNanoIntervalToNamedTuple(
const MonthDayNanoIntervalType::MonthDayNanos& interval) {
OwnedRef tuple(PyStructSequence_New(&MonthDayNanoTupleType));
OwnedRef tuple(PyStructSequence_New(MonthDayNanoTupleType));
if (ARROW_PREDICT_FALSE(tuple.obj() == nullptr)) {
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/src/arrow/python/decimal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Status InternalDecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type,
return InternalDecimalFromPythonDecimal<ArrowDecimal>(obj, arrow_type, out);
} else {
return Status::TypeError("int or Decimal object expected, got ",
Py_TYPE(obj)->tp_name);
internal::PyObject_StdStringTypeName(obj));
}
}

Expand Down
4 changes: 2 additions & 2 deletions python/pyarrow/src/arrow/python/extension_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ std::string PyExtensionType::ToString(bool show_metadata) const {

std::stringstream ss;
OwnedRef instance(GetInstance());
ss << "extension<" << this->extension_name() << "<" << Py_TYPE(instance.obj())->tp_name
<< ">>";
ss << "extension<" << this->extension_name() << "<"
<< internal::PyObject_StdStringTypeName(instance.obj()) << ">>";
return ss.str();
}

Expand Down
Loading