Skip to content

parse_config: improve config loading#2351

Open
lasers wants to merge 1 commit into
ultrabug:masterfrom
lasers:parse_config_fallback
Open

parse_config: improve config loading#2351
lasers wants to merge 1 commit into
ultrabug:masterfrom
lasers:parse_config_fallback

Conversation

@lasers

@lasers lasers commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This attempts config loading utf-8-sig first (rather than utf-8) with fallback to command file.

It looks like py3status switched from utf-8 to file (with fallback utf-8) sometimes in the past to better handle files. However, because file is now tried first, it introduced new issues such as...

  1. make file a hard dependency.
  2. bsd file doesn't have --mime-encoding
  3. adding timeout to file subprocess call
  4. slow

I'm suggesting that we try again with utf-8-sig first, then fallback to command file rather than staying with the other way around. The final fallback is default locale (instead of explicit utf-8), but we tried utf-8-sig first anyway.


Strategy Comparison.

case        | file first     | utf-8 first    | utf-8-sig first
------------+----------------+----------------+-----------------
ascii       | ok             | ok             | ok
utf-8       | ok             | ok             | ok
utf-8-sig   | parse_fail:bom | parse_fail:bom | ok
latin-1     | ok             | fallback->ok   | fallback->ok
utf-16      | ok             | fallback->ok   | fallback->ok

Benchmark.

branch                  | mean_seconds | vs_master
------------------------+--------------+----------------
master                  | 0.006011611  | baseline
parse_config_fallback   | 0.000251349  | 95.82% faster

@lasers
lasers force-pushed the parse_config_fallback branch from 2b518cc to b6a51a4 Compare July 21, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant