__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
"""
Validating highly nested schemas shouldn't cause exponential time blowups.

See https://github.com/python-jsonschema/jsonschema/issues/1097.
"""
from itertools import cycle

from jsonschema.validators import validator_for

metaschemaish = {
    "$id": "https://example.com/draft/2020-12/schema/strict",
    "$schema": "https://json-schema.org/draft/2020-12/schema",

    "$vocabulary": {
        "https://json-schema.org/draft/2020-12/vocab/core": True,
        "https://json-schema.org/draft/2020-12/vocab/applicator": True,
        "https://json-schema.org/draft/2020-12/vocab/unevaluated": True,
        "https://json-schema.org/draft/2020-12/vocab/validation": True,
        "https://json-schema.org/draft/2020-12/vocab/meta-data": True,
        "https://json-schema.org/draft/2020-12/vocab/format-annotation": True,
        "https://json-schema.org/draft/2020-12/vocab/content": True
    },
    "$dynamicAnchor": "meta",

    "$ref": "https://json-schema.org/draft/2020-12/schema",
    "unevaluatedProperties": False,
}


def nested_schema(levels):
    """
    Produce a schema which validates deeply nested objects and arrays.
    """

    names = cycle(["foo", "bar", "baz", "quux", "spam", "eggs"])
    schema = {"type": "object", "properties": {"ham": {"type": "string"}}}
    for _, name in zip(range(levels - 1), names):
        schema = {"type": "object", "properties": {name: schema}}
    return schema


validator = validator_for(metaschemaish)(metaschemaish)

if __name__ == "__main__":
    from pyperf import Runner
    runner = Runner()

    not_nested = nested_schema(levels=1)
    runner.bench_func("not nested", lambda: validator.is_valid(not_nested))

    for levels in range(1, 11, 3):
        schema = nested_schema(levels=levels)
        runner.bench_func(
            f"nested * {levels}",
            lambda schema=schema: validator.is_valid(schema),
        )

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
issue232 Folder 0755
__init__.py File 70 B 0644
issue232.py File 521 B 0644
json_schema_test_suite.py File 320 B 0644
nested_schemas.py File 1.85 KB 0644
subcomponents.py File 1.09 KB 0644
unused_registry.py File 939 B 0644
validator_creation.py File 285 B 0644
Filemanager