diff --git a/python/pyarrow/_flight.pyx b/python/pyarrow/_flight.pyx index 2ab0ab618ae..b9a54483edd 100644 --- a/python/pyarrow/_flight.pyx +++ b/python/pyarrow/_flight.pyx @@ -324,6 +324,9 @@ cdef class Action(_Weakrefable): CAction.Deserialize(tobytes(serialized))) return action + def __reduce__(self): + return Action.deserialize, (self.serialize(),) + def __eq__(self, Action other): return self.action == other.action @@ -391,6 +394,9 @@ cdef class Result(_Weakrefable): CFlightResult.Deserialize(tobytes(serialized))))) return result + def __reduce__(self): + return Result.deserialize, (self.serialize(),) + def __eq__(self, Result other): return deref(self.result.get()) == deref(other.result.get()) @@ -437,6 +443,9 @@ cdef class BasicAuth(_Weakrefable): def serialize(self): return GetResultValue(self.basic_auth.get().SerializeToString()) + def __reduce__(self): + return BasicAuth.deserialize, (self.serialize(),) + def __eq__(self, BasicAuth other): return deref(self.basic_auth.get()) == deref(other.basic_auth.get()) @@ -596,6 +605,9 @@ cdef class FlightDescriptor(_Weakrefable): CFlightDescriptor.Deserialize(tobytes(serialized))) return descriptor + def __reduce__(self): + return FlightDescriptor.deserialize, (self.serialize(),) + def __eq__(self, FlightDescriptor other): return self.descriptor == other.descriptor @@ -635,6 +647,9 @@ cdef class Ticket(_Weakrefable): CTicket.Deserialize(tobytes(serialized))) return ticket + def __reduce__(self): + return Ticket.deserialize, (self.serialize(),) + def __eq__(self, Ticket other): return self.c_ticket == other.c_ticket @@ -665,6 +680,10 @@ cdef class Location(_Weakrefable): return NotImplemented return self.location.Equals(( other).location) + def __reduce__(self): + # Location has no protobuf serialize helper; URI is sufficient. + return Location, (self.uri,) + @staticmethod def for_grpc_tcp(host, port): """Create a Location for a TCP-based gRPC service.""" @@ -829,6 +848,9 @@ cdef class FlightEndpoint(_Weakrefable): CFlightEndpoint.Deserialize(tobytes(serialized))) return endpoint + def __reduce__(self): + return FlightEndpoint.deserialize, (self.serialize(),) + def __repr__(self): return (f"