Skip to content

Strategy deduplication performance issue and incorrect handling of empty tuple schemas #90

@Bitshifter-9

Description

@Bitshifter-9
  1. Performance issue: O(n²) strategy deduplication in _MetaSchemaBuilder
    Location: genson/schema/builder.py url:https://github.com/wolverdude/GenSON/blob/master/genson/schema/builder.py
    Current behavior:
    schema strategies are deduplicated using a list with repeated membership checks,
    This results in O(n²) time complexity
            unique_schema_strategies = []
            for schema_strategy in schema_strategies:
                if schema_strategy not in unique_schema_strategies:
                    unique_schema_strategies.append(schema_strategy)

2.Bug: Empty tuple schemas produce an unexpected schema item
Location: genson/schema/strategies/array.py url:https://github.com/wolverdude/GenSON/blob/master/genson/schema/strategies/array.py
Steps to reproduce


  from genson import SchemaBuilder
  builder = SchemaBuilder()
  builder.add_schema({'type': 'array', 'items': []})
  schema = builder.to_schema()
  

current output:{'type': 'array', 'items': [{}]} Expected output:{'type': 'array', 'items': []}

The Tuple strategy initializes its internal _items list with a single empty schema instance, even when the tuple definition is explicitly empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions