konradhalas / dacite

Simple creation of data classes from dictionaries.
MIT License
1.72k stars 106 forks source link

Introduce basic cache #208

Closed mciszczon closed 1 year ago

mciszczon commented 1 year ago

I salvaged some useful parts from feature/performance-improvements branch:

Fixes #92 Fixes #129

mciszczon commented 1 year ago
----------------------------------------------------------------------------------------------------------- benchmark: 16 tests ------------------------------------------------------------------------------------------------------------
Name (time in us)                                       Min                     Max                    Mean                StdDev                  Median                 IQR            Outliers          OPS            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_casting (0002_40ed94e)                         12.5829 (1.0)          151.0421 (1.30)          13.4459 (1.0)          3.1554 (1.0)           12.9999 (1.0)        0.3760 (1.0)      345;1636  74,372.1063 (1.0)       19705           1
test_casting (0001_6eecf29)                         17.0842 (1.36)         115.8749 (1.0)           18.1971 (1.35)         3.3784 (1.07)          17.5829 (1.35)       0.5832 (1.55)     779;1748  54,953.7174 (0.74)      27242           1
test_basic_scenario (0002_40ed94e)                  99.5419 (7.91)       1,855.7082 (16.01)        106.3011 (7.91)        30.3248 (9.61)         102.1661 (7.86)       5.2499 (13.96)     143;294   9,407.2375 (0.13)       4547           1
test_basic_scenario (0001_6eecf29)                 108.9580 (8.66)         436.6671 (3.77)         115.6197 (8.60)        17.2480 (5.47)         110.9591 (8.54)       4.5821 (12.19)     202;384   8,649.0447 (0.12)       4236           1
test_collection_of_union (0002_40ed94e)            189.5831 (15.07)        957.9170 (8.27)         201.4600 (14.98)       22.1082 (7.01)         197.1045 (15.16)     10.6669 (28.37)     171;195   4,963.7643 (0.07)       2814           1
test_collection_of_union (0001_6eecf29)            196.0830 (15.58)      7,243.9159 (62.51)        208.2745 (15.49)      109.2157 (34.61)        202.0001 (15.54)     10.8753 (28.92)       3;297   4,801.3548 (0.06)       4224           1
test_strict_unions_match (0002_40ed94e)          3,913.2081 (310.99)     5,663.8331 (48.88)      4,115.4318 (306.07)     190.5958 (60.40)      4,081.7922 (313.99)   177.1037 (470.99)       20;7     242.9879 (0.00)        251           1
test_union_matching (0002_40ed94e)               3,929.5841 (312.30)     4,501.3749 (38.85)      4,117.6045 (306.23)     112.9594 (35.80)      4,106.5840 (315.89)   154.9894 (412.18)       82;3     242.8597 (0.00)        235           1
test_type_hooks (0002_40ed94e)                   3,930.7498 (312.39)    19,053.0419 (164.43)     4,275.8415 (318.00)   1,195.5328 (378.89)     4,137.9377 (318.31)   198.1671 (527.01)        3;5     233.8721 (0.00)        250           1
test_forward_references (0002_40ed94e)           3,948.6249 (313.81)     4,437.4580 (38.30)      4,124.8990 (306.78)     110.0408 (34.87)      4,112.7080 (316.37)   190.9577 (507.84)       83;0     242.4302 (0.00)        234           1
test_strict_unions_match (0001_6eecf29)          4,723.8332 (375.42)     5,290.5839 (45.66)      4,958.0852 (368.74)     113.3862 (35.93)      4,965.2291 (381.94)   143.1659 (380.74)       62;2     201.6908 (0.00)        202           1
test_union_matching (0001_6eecf29)               4,740.7080 (376.76)     5,523.4579 (47.67)      4,961.3923 (368.99)     120.7325 (38.26)      4,956.7501 (381.29)   161.3330 (429.05)       54;2     201.5563 (0.00)        198           1
test_type_hooks (0001_6eecf29)                   4,754.4171 (377.85)     5,398.1249 (46.59)      4,979.4814 (370.33)     116.7121 (36.99)      4,981.6665 (383.21)   158.3330 (421.07)       65;3     200.8241 (0.00)        202           1
test_forward_references (0001_6eecf29)           4,761.7920 (378.43)     5,355.4170 (46.22)      5,000.9056 (371.93)     108.1306 (34.27)      4,999.2709 (384.56)   133.9369 (356.19)       59;5     199.9638 (0.00)        196           1
test_parsing_multiple_items (0002_40ed94e)     102,809.2501 (>1000.0)  110,067.1249 (949.88)   103,999.2332 (>1000.0)  2,182.2204 (691.59)   103,371.7495 (>1000.0)  697.3750 (>1000.0)       1;1       9.6155 (0.00)         10           1
test_parsing_multiple_items (0001_6eecf29)     123,481.5421 (>1000.0)  124,703.1249 (>1000.0)  123,993.8280 (>1000.0)    408.9902 (129.62)   123,896.0830 (>1000.0)  588.3124 (>1000.0)       3;0       8.0649 (0.00)          8           1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
juan-leon commented 1 year ago

Any chances of having this change in an official tag / published version soon?

konradhalas commented 1 year ago

@juan-leon done! :) https://pypi.org/project/dacite/1.8.0/

juan-leon commented 1 year ago

Great!

Thanks a lot; this change makes a difference for me (according to py-spy :-) )