|
|
@@ -259,6 +259,25 @@ get_subdata(size_t n, size_t count) const {
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements pickle support.
|
|
|
+ */
|
|
|
+template<class Element>
|
|
|
+INLINE PyObject *Extension<PointerToArray<Element> >::
|
|
|
+__reduce__(PyObject *self) const {
|
|
|
+ // This preserves the distinction between a null vs. an empty PTA, though I'm
|
|
|
+ // not sure that this distinction matters to anyone.
|
|
|
+ if (this->_this->is_null()) {
|
|
|
+ return Py_BuildValue("O()", Py_TYPE(self));
|
|
|
+ }
|
|
|
+ else if (this->_this->empty()) {
|
|
|
+ return Py_BuildValue("O(())", Py_TYPE(self));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return Py_BuildValue("O(N)", Py_TYPE(self), get_data());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Same as get_element(), this returns the nth element of the array.
|
|
|
*/
|
|
|
@@ -304,6 +323,15 @@ get_subdata(size_t n, size_t count) const {
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements pickle support.
|
|
|
+ */
|
|
|
+template<class Element>
|
|
|
+INLINE PyObject *Extension<ConstPointerToArray<Element> >::
|
|
|
+__reduce__(PyObject *self) const {
|
|
|
+ return Py_BuildValue("O(N)", Py_TYPE(self), get_data());
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* This is used to implement the buffer protocol, in order to allow efficient
|
|
|
* access to the array data through a Python multiview object.
|