A hands-on localhost lab comparing configparser and json.load for nested application configuration.
4 min read
Load equivalent app config (nested sections/keys) from INI via configparser vs JSON via json.load, many iterations. This lab reports loads/s on Linux localhost.
It is not json dumps compact vs indent (lab 75) and not json vs orjson/msgpack (lab 36). Focus: configparser vs JSON file load for settings.
Related links:
Lab honesty (1 Oct 2026 IST): Python 3.13.5. Affiliates: 0. No Docker. Same logical sections in .ini and .json.
Verdict up front (medium ≈ 22 sections / 306 keys, INI 6124 B / JSON 8751 B): json.load file ~22214.8 loads/s; json.loads ~30021.9; configparser.read file ~646.5; read_string ~628.1. JSON wins on speed/structure; INI wins on ops familiarity and comments.
| Arm | Pattern |
|---|---|
ConfigParser.read(path) | classic INI file |
read_string | INI already in memory |
json.load(file) | JSON file |
json.loads | JSON string |
load + one get / key | parse then access |
Script: lab-evidence/104-configparser-vs-json/results/run_lab.py.
| Arm | loads/s |
|---|---|
| json.loads (string) | 30021.9 |
| json.load (file) | 22214.8 |
| configparser read_string | 628.1 |
| configparser read file | 646.5 |
JSON file load is roughly ~34× configparser here.
| Size | configparser | json.load |
|---|---|---|
| small | 3173.7 | 68970.3 |
| medium | 646.5 | 22214.8 |
| large | 101.5 | 4422.5 |
Gap stays large as configs grow — configparser’s section/key parsing is heavier than JSON’s C parser on this box.
.ini, flat-ish sections (nested via naming).Most services parse config once at boot. Even then, faster JSON shortens fork-heavy worker bring-up when each child re-reads settings. If you only edit config weekly, human ergonomics may beat a few thousand loads/s.
read_string vs read(file) is secondary next to format choice.configparser supports interpolation and # / ; comments — JSON does not (without a non-standard super-set). If your ops team lives in annotated INI files, converting solely for a loads/s win may cost more in process than it saves at boot. Conversely, if configs are generated by machines, JSON (or TOML) is usually clearer.
Deep nesting is awkward in INI (fake hierarchy with section.subsection names). JSON objects/arrays map naturally to feature flags, allow-lists, and per-tenant blocks. That structural fit often matters more than the ~34× file-load gap measured on medium here.
Evidence: summary.json, summary.txt, fixtures/.
One Linux box. Synthetic section grids. Not TOML/tomllib, not YAML. Not multi-GB configs.
On a medium nested config, json.load ~22214.8 loads/s beat configparser.read ~646.5 loads/s. Pick JSON for speed/structure, INI for editable ops configs — not dumps-indent or orjson labs.
Lab evidence
Lab 1 Oct 2026 IST. Python 3.13.5. medium: json_load_file 22214.8 loads/s; configparser_read_file 646.5; json_loads 30021.9. Not lab 75 dumps / lab 36 orjson. Affiliates: 0. Evidence: lab-evidence/104-configparser-vs-json/.
Hands-on tomllib vs json.load nested config lab: real loads/s (stdlib TOML read-only), measured on Linux localhost today in this hands-on lab for SREs.
Lab1 Oct 20264 min read
Hands-on itertools.islice vs list slice window lab: real ops/s taking ranges from sequences, measured on Linux localhost in this hands-on lab for SREs.
Lab1 Oct 20264 min read
Hands-on heapq.merge vs sorted(chain) multi-way merge: real records/s on pre-sorted lists, measured on Linux localhost today in this hands-on lab for SREs.
Lab1 Oct 20264 min read