def get_estimated_size_and_observables(self, value, nested=False): if isinstance(value, observable.ObservableMixin): # FastPrimitivesCoderImpl can presumably encode the elements too. return 1, [(value, self)] out = ByteCountingOutputStream() self.encode_to_stream(value, out, nested) return out.get_count(), []
def get_estimated_size_and_observables(self, value, nested=False): if isinstance(value, observable.ObservableMixin): # FastPrimitivesCoderImpl can presumably encode the elements too. return 1, [(value, self)] else: out = ByteCountingOutputStream() self.encode_to_stream(value, out, nested) return out.get_count(), []
def estimate_size(self, value, nested=False): """Estimates the encoded size of the given value, in bytes.""" out = ByteCountingOutputStream() self.encode_to_stream(value, out, nested) return out.get_count()