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

Function InternalDecimalFromPyObject

python/pyarrow/src/arrow/python/decimal.cc:148–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146
147template <typename ArrowDecimal>
148Status InternalDecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type,
149 ArrowDecimal* out) {
150 ARROW_DCHECK_NE(obj, NULLPTR);
151 ARROW_DCHECK_NE(out, NULLPTR);
152
153 if (IsPyInteger(obj)) {
154 // TODO: add a fast path for small-ish ints
155 std::string string;
156 RETURN_NOT_OK(PyObject_StdStringStr(obj, &string));
157 return DecimalFromStdString(string, arrow_type, out);
158 } else if (PyDecimal_Check(obj)) {
159 return InternalDecimalFromPythonDecimal<ArrowDecimal>(obj, arrow_type, out);
160 } else {
161 return Status::TypeError("int or Decimal object expected, got ",
162 Py_TYPE(obj)->tp_name);
163 }
164}
165
166} // namespace
167

Callers 1

DecimalFromPyObjectFunction · 0.85

Calls 5

IsPyIntegerFunction · 0.85
PyObject_StdStringStrFunction · 0.85
DecimalFromStdStringFunction · 0.85
PyDecimal_CheckFunction · 0.85
TypeErrorFunction · 0.50

Tested by

no test coverage detected