import os def generate_dense_json(output_path="note_5mb.json", target_mb=5.0): target_bytes = int(target_mb * 1024 * 1024) with open(output_path, "w", encoding="utf-8") as f: f.write("{\n") bytes_written = 2 i = 0 while bytes_written < target_bytes - 128: entry = f' "item_{i}": {{"id": {i}}},\n' f.write(entry) bytes_written += len(entry.encode("utf-8")) i += 1 final_entry = f' "item_{i}": {{"id": {i}}}\n' f.write(final_entry) f.write("}\n") actual_size = os.path.getsize(output_path) print(f"File created: {output_path}") print(f"Number of objects: {i + 1}") print(f"Final size: {actual_size:,} bytes ({actual_size / (1024 * 1024):.2f} MB)") if __name__ == "__main__": generate_dense_json()