1010from ..binary import encode_binary
1111
1212
13- def size (data : Any , format : Literal ['zon ' , 'binary' , 'json' ] = 'zon ' ) -> int :
13+ def size (data : Any , format : Literal ['zonf ' , 'binary' , 'json' ] = 'zonf ' ) -> int :
1414 """Calculate the encoded size of data in different formats.
1515
1616 Args:
1717 data: Data to measure
18- format: Format to use ('zon ', 'binary', or 'json')
18+ format: Format to use ('zonf ', 'binary', or 'json')
1919
2020 Returns:
2121 Size in bytes
2222
2323 Example:
2424 >>> data = {"name": "Alice", "age": 30}
25- >>> size(data, 'zon ')
25+ >>> size(data, 'zonf ')
2626 45
2727 >>> size(data, 'json')
2828 28
2929 """
30- if format == 'zon ' :
30+ if format == 'zonf ' :
3131 return len (encode (data ).encode ('utf-8' ))
3232 elif format == 'binary' :
3333 return len (encode_binary (data ))
@@ -52,7 +52,7 @@ def compare_formats(data: Any) -> Dict[str, Any]:
5252 >>> result['savings']['zon_vs_json']
5353 35.5
5454 """
55- zon_size = size (data , 'zon ' )
55+ zonf_size = size (data , 'zonf ' )
5656 binary_size = size (data , 'binary' )
5757 json_size = size (data , 'json' )
5858
@@ -64,13 +64,13 @@ def calc_savings(smaller: int, larger: int) -> float:
6464 return (1 - smaller / larger ) * 100
6565
6666 return {
67- 'zon ' : zon_size ,
67+ 'zonf ' : zonf_size ,
6868 'binary' : binary_size ,
6969 'json' : json_size ,
7070 'savings' : {
71- 'zon_vs_json ' : calc_savings (zon_size , json_size ),
71+ 'zonf_vs_json ' : calc_savings (zonf_size , json_size ),
7272 'binary_vs_json' : calc_savings (binary_size , json_size ),
73- 'binary_vs_zon ' : calc_savings (binary_size , zon_size )
73+ 'binary_vs_zonf ' : calc_savings (binary_size , zonf_size )
7474 }
7575 }
7676
@@ -194,8 +194,8 @@ def compare(data1: Any, data2: Any) -> Dict[str, Any]:
194194 'equal' : data1 == data2 ,
195195 'data1_type' : type (data1 ).__name__ ,
196196 'data2_type' : type (data2 ).__name__ ,
197- 'data1_size' : size (data1 , 'zon ' ),
198- 'data2_size' : size (data2 , 'zon ' )
197+ 'data1_size' : size (data1 , 'zonf ' ),
198+ 'data2_size' : size (data2 , 'zonf ' )
199199 }
200200
201201
@@ -220,7 +220,7 @@ def is_safe(data: Any, max_depth: int = 10, max_size: int = 1000000) -> Dict[str
220220 stats = analyze (data )
221221 depth = stats ['depth' ]
222222
223- encoded_size = size (data , 'zon ' )
223+ encoded_size = size (data , 'zonf ' )
224224
225225 safe = depth <= max_depth and encoded_size <= max_size
226226
0 commit comments