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

Method GetInstance

python/pyarrow/src/arrow/python/extension_type.cc:162–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162PyObject* PyExtensionType::GetInstance() const {
163 if (!type_instance_) {
164 PyErr_SetString(PyExc_TypeError, "Not an instance");
165 return nullptr;
166 }
167 ARROW_DCHECK(PyWeakref_CheckRef(type_instance_.obj()));
168 PyObject* inst = NULL;
169 int result = PyWeakref_GetRef(type_instance_.obj(), &inst);
170 if (result == 1) {
171 // Alive: inst is a new strong reference
172 return inst;
173 } else if (result == 0) {
174 // Weakref is dead, must reconstruct from serialized form
175 // XXX cache again?
176 return DeserializeExtInstance(type_class_.obj(), storage_type_, serialized_);
177 } else {
178 // -1 = exception
179 return nullptr;
180 }
181}
182
183Status PyExtensionType::SetInstance(PyObject* inst) const {
184 // Check we have the right type

Callers 1

ExtensionEqualsMethod · 0.45

Calls 1

DeserializeExtInstanceFunction · 0.85

Tested by

no test coverage detected