ShopperCove
Menu
All writingBlogTopicsCategoriesAboutRSS
Blog
Categories
Observability & SRE62All categories
About

Plate 35

  1. Blog
  2. /Observability & SRE

configparser vs JSON Config Load: Localhost Lab

A hands-on localhost lab comparing configparser and json.load for nested application configuration.

Aditya Challa·30 September 2026·4 min read

Lab
On this page
  1. Intro — what this post promises
  2. Arms
  3. Lab topology
  4. Lead table — medium config (p50)
  5. Scale sketch (file load)
  6. INI vs JSON product tradeoffs
  7. Cold start context
  8. Reading it
  9. Interpolation and comments
  10. Nested data shapes
  11. Pitfalls
  12. Reproduce
  13. Limits
  14. Takeaway

Intro — what this post promises

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:

  • json dumps compact vs indent localhost lab
  • json vs orjson msgpack localhost lab
  • zlib vs gzip compress localhost lab
  • difflib vs set ops localhost lab
  • groupby vs manual localhost lab
  • methodcaller vs getattr localhost lab
  • queue vs deque handoff localhost lab
  • stringio vs list join localhost lab

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.


Arms

ArmPattern
ConfigParser.read(path)classic INI file
read_stringINI already in memory
json.load(file)JSON file
json.loadsJSON string
load + one get / keyparse then access

Lab topology

small / medium / large section grids · 7 rounds · p50
metric: loads/s = 1 / p50_s

Script: lab-evidence/104-configparser-vs-json/results/run_lab.py.


Lead table — medium config (p50)

Armloads/s
json.loads (string)30021.9
json.load (file)22214.8
configparser read_string628.1
configparser read file646.5

JSON file load is roughly ~34× configparser here.


Scale sketch (file load)

Sizeconfigparserjson.load
small3173.768970.3
medium646.522214.8
large101.54422.5

Gap stays large as configs grow — configparser’s section/key parsing is heavier than JSON’s C parser on this box.


INI vs JSON product tradeoffs

  • INI / configparser: comments, interpolation, ops-familiar .ini, flat-ish sections (nested via naming).
  • JSON: nested objects/arrays, types beyond strings (until you cast), ubiquitous tooling; no comments in strict JSON.
  • Startup-once apps: either is fine. Hot reload / many workers parsing often: prefer JSON (or a binary/cache form).

Cold start context

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.


Reading it

  • Prefer JSON when load rate or nested structure matters.
  • Prefer INI when humans edit by hand and want comments.
  • read_string vs read(file) is secondary next to format choice.
  • Typed JSON still needs validation — speed ≠ schema safety.

Interpolation and comments

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.


Nested data shapes

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.


Pitfalls

  • Reloading INI on every request in a hot path.
  • Comparing indented JSON dumps size to minified without noting it (fixtures here use indent=2).
  • Assuming configparser preserves types (values are strings).
  • Cannibalizing orjson benches — different question.

Reproduce

python3 lab-evidence/104-configparser-vs-json/results/run_lab.py

Evidence: summary.json, summary.txt, fixtures/.


Limits

One Linux box. Synthetic section grids. Not TOML/tomllib, not YAML. Not multi-GB configs.


Takeaway

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.

configparserjson.loadini configapp settingspython configlocalhost labsreloads/s

Lab evidence

What I found running this

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/.

Notes when a lab post goes up

Occasional email for new hands-on reviews. No sequence and no sponsors.

Related links

  • Plate 95

    tomllib vs JSON Config Load: Localhost Lab

    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.

    1 Oct 2026

  • Plate 12

    islice vs list Slice Windows: Localhost Lab

    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.

    Observability & SRE · 1 Oct 2026

  • Plate 07

    heapq.merge vs sorted(chain): Localhost Lab

    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.

    Observability & SRE · 1 Oct 2026

On this page

  1. Intro — what this post promises
  2. Arms
  3. Lab topology
  4. Lead table — medium config (p50)
  5. Scale sketch (file load)
  6. INI vs JSON product tradeoffs
  7. Cold start context
  8. Reading it
  9. Interpolation and comments
  10. Nested data shapes
  11. Pitfalls
  12. Reproduce
  13. Limits
  14. Takeaway
All writingBlogCategoriesTopicsAboutPrivacyRSS

© 2026 ShopperCove