Serializes obj to an avro-format byte array and returns it.

def dumps(self, obj):
        """
        Serializes obj to an avro-format byte array and returns it.
        """
        out = BytesIO()
        try:
            self.dump(obj, out)
            return out.getvalue()
        finally:
            out.close()