set the reader_schema to None if it matches the writer schema
MODIFY
fastavro/_read.pyx
fastavro/_read.pyx
@@ -664,8 +664,13 @@ class reader:
self.schema = self.writer_schema = \
json.loads(self.metadata['avro.schema'])
self.codec = self.metadata.get('avro.codec', 'null')
+
self.reader_schema = reader_schema
+ if self.writer_schema == reader_schema:
+ # No need for the reader schema if they are the same
+ reader_schema = None
+
acquaint_schema(self.writer_schema)
if reader_schema:
populate_schema_defs(reader_schema)
@@ -690,8 +695,14 @@ iter_avro = reader
cpdef schemaless_reader(fo, writer_schema, reader_schema=None):
acquaint_schema(writer_schema)
+
+ if writer_schema == reader_schema:
+ # No need for the reader schema if they are the same
+ reader_schema = None
+
if reader_schema:
populate_schema_defs(reader_schema)
+
return read_data(fo, writer_schema, reader_schema)

MODIFY
fastavro/_read_py.py
fastavro/_read_py.py
@@ -578,8 +578,13 @@ class reader:
self.schema = self.writer_schema = \
json.loads(self.metadata['avro.schema'])
self.codec = self.metadata.get('avro.codec', 'null')
+
self.reader_schema = reader_schema
+ if self.writer_schema == reader_schema:
+ # No need for the reader schema if they are the same
+ reader_schema = None
+
acquaint_schema(self.writer_schema)
if reader_schema:
populate_schema_defs(reader_schema)
@@ -625,8 +630,14 @@ def schemaless_reader(fo, writer_schema, reader_schema=None):
Note: The ``schemaless_reader`` can only read a single record.
"""
acquaint_schema(writer_schema)
+
+ if writer_schema == reader_schema:
+ # No need for the reader schema if they are the same
+ reader_schema = None
+
if reader_schema:
populate_schema_defs(reader_schema)
+
return read_data(fo, writer_schema, reader_schema)

set the reader_schema to None if it matches the writer schema