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

Method ExtensionEquals

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

Source from the content-addressed store, hash-verified

99 type_instance_(inst) {}
100
101bool PyExtensionType::ExtensionEquals(const ExtensionType& other) const {
102 PyAcquireGIL lock;
103
104 if (other.extension_name() != extension_name()) {
105 return false;
106 }
107 const auto& other_ext = checked_cast<const PyExtensionType&>(other);
108 int res = -1;
109 if (!type_instance_) {
110 if (other_ext.type_instance_) {
111 return false;
112 }
113 // Compare Python types
114 res = PyObject_RichCompareBool(type_class_.obj(), other_ext.type_class_.obj(), Py_EQ);
115 } else {
116 if (!other_ext.type_instance_) {
117 return false;
118 }
119 // Compare Python instances
120 OwnedRef left(GetInstance());
121 OwnedRef right(other_ext.GetInstance());
122 if (!left || !right) {
123 goto error;
124 }
125 res = PyObject_RichCompareBool(left.obj(), right.obj(), Py_EQ);
126 }
127 if (res == -1) {
128 goto error;
129 }
130 return res == 1;
131
132error:
133 // Cannot propagate error
134 PyErr_WriteUnraisable(nullptr);
135 return false;
136}
137
138std::shared_ptr<Array> PyExtensionType::MakeArray(std::shared_ptr<ArrayData> data) const {
139 ARROW_DCHECK_EQ(data->type->id(), Type::EXTENSION);

Callers

nothing calls this directly

Calls 3

extension_nameFunction · 0.50
extension_nameMethod · 0.45
GetInstanceMethod · 0.45

Tested by

no test coverage detected