| 99 | type_instance_(inst) {} |
| 100 | |
| 101 | bool 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 | |
| 132 | error: |
| 133 | // Cannot propagate error |
| 134 | PyErr_WriteUnraisable(nullptr); |
| 135 | return false; |
| 136 | } |
| 137 | |
| 138 | std::shared_ptr<Array> PyExtensionType::MakeArray(std::shared_ptr<ArrayData> data) const { |
| 139 | ARROW_DCHECK_EQ(data->type->id(), Type::EXTENSION); |
nothing calls this directly
no test coverage detected