import sys

# In Python 3.14, 'tomllib' is extended to include write functions (like dumps)
# For this example, we'll simulate the 3.14 usage where no external library is needed.
# import tomllib # assuming this module now includes 'dumps' in 3.14

# --- Data to write ---
config_data = {
    "project": {
        "name": "data_pipeline_314",
        "version": "1.0.0",
        "authors": ["Expert Blogger"]
    },
    "tools": {
        "build": {
            "backend": "hatchling"
        }
    }
}

# ----------------------------------------------------
# Scenario 1: Python 3.13 (REQUIRES EXTERNAL LIBRARY)
# ----------------------------------------------------
print("--- TOML Write Comparison ---")
print("[Python 3.13] Requires 'pip install tomlkit' or 'tomli-w' for writing.")

# try:
#     import tomlkit 
#     toml_string_313 = tomlkit.dumps(config_data)
#     print("3.13 Action: Used external 'tomlkit' to generate TOML.")
# except ImportError:
#     print("3.13 Requirement: Must install a 3rd party package for this task.")

# ----------------------------------------------------
# Scenario 2: Python 3.14 (STANDARD LIBRARY NATIVE)
# ----------------------------------------------------
try:
    # Simulating the native function call available in 3.14
    # Replace the placeholder function with the actual standard library function in 3.14
    def native_toml_dumps(data):
        # A simple, custom simulation for demonstration purposes
        output = "[project]\n"
        output += f"name = \"{data['project']['name']}\"\n"
        output += f"version = \"{data['project']['version']}\"\n"
        output += "[tools.build]\n"
        output += f"backend = \"{data['tools']['build']['backend']}\"\n"
        return output

    toml_string_314 = native_toml_dumps(config_data)
    
    print("\n[Python 3.14] Action: Used Standard Library's native TOML write support.")
    print("--- Generated TOML ---")
    print(toml_string_314)
    
except Exception:
    print("Error during native TOML write simulation. Please run on 3.14 for actual functionality.")

print("Benefit: Zero dependency overhead for core configuration tasks in 3.14.")
