@@ -476,6 +476,7 @@ def t():
476
476
477
477
478
478
set_of_ints_data = ({i for i in range (1000 )}, {str (i ) for i in range (1000 )})
479
+ set_of_ints_duplicates = ([i for i in range (100 )] * 10 , [str (i ) for i in range (100 )] * 10 )
479
480
480
481
481
482
@skip_pydantic
@@ -500,6 +501,16 @@ def t():
500
501
v .validate_python (set_of_ints_data [1 ])
501
502
502
503
504
+ @pytest .mark .benchmark (group = 'Set[int]' )
505
+ def test_set_of_ints_core_duplicates (benchmark ):
506
+ v = SchemaValidator ({'type' : 'set' , 'items_schema' : {'type' : 'int' }})
507
+
508
+ @benchmark
509
+ def t ():
510
+ v .validate_python (set_of_ints_duplicates [0 ])
511
+ v .validate_python (set_of_ints_duplicates [1 ])
512
+
513
+
503
514
@skip_pydantic
504
515
@pytest .mark .benchmark (group = 'Set[int] JSON' )
505
516
def test_set_of_ints_pyd_json (benchmark ):
@@ -518,6 +529,18 @@ def t():
518
529
def test_set_of_ints_core_json (benchmark ):
519
530
v = SchemaValidator ({'type' : 'set' , 'items_schema' : {'type' : 'int' }})
520
531
532
+ json_data = [json .dumps (list (d )) for d in set_of_ints_duplicates ]
533
+
534
+ @benchmark
535
+ def t ():
536
+ v .validate_json (json_data [0 ])
537
+ v .validate_json (json_data [1 ])
538
+
539
+
540
+ @pytest .mark .benchmark (group = 'Set[int] JSON' )
541
+ def test_set_of_ints_core_json_duplicates (benchmark ):
542
+ v = SchemaValidator ({'type' : 'set' , 'items_schema' : {'type' : 'int' }})
543
+
521
544
json_data = [json .dumps (list (d )) for d in set_of_ints_data ]
522
545
523
546
@benchmark
@@ -527,6 +550,7 @@ def t():
527
550
528
551
529
552
frozenset_of_ints = frozenset ({i for i in range (1000 )})
553
+ frozenset_of_ints_duplicates = [i for i in range (100 )] * 10
530
554
531
555
532
556
@skip_pydantic
@@ -545,6 +569,13 @@ def test_frozenset_of_ints_core(benchmark):
545
569
benchmark (v .validate_python , frozenset_of_ints )
546
570
547
571
572
+ @pytest .mark .benchmark (group = 'FrozenSet[int]' )
573
+ def test_frozenset_of_ints_duplicates_core (benchmark ):
574
+ v = SchemaValidator ({'type' : 'frozenset' , 'items_schema' : {'type' : 'int' }})
575
+
576
+ benchmark (v .validate_python , frozenset_of_ints_duplicates )
577
+
578
+
548
579
dict_of_ints_data = ({str (i ): i for i in range (1000 )}, {str (i ): str (i ) for i in range (1000 )})
549
580
550
581
0 commit comments