naturalsize() ignores the locale decimal separator

Aperta
#460 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ekanshul ci sta già lavorando.

Dal 20/10/2026.

  • #463 di @ekanshul — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Read the naturalsize() implementation and the decimal_separator() usage in intword() and intcomma(). Reproduce the comma-decimal example for a listed locale, then check the existing naturalsize benchmarks, including the regression noted for test_naturalsize. Done means naturalsize() uses the locale separator while preserving the default-period performance path and the benchmark result is checked; the issue leaves sequencing around PRs #403, #457, and #367 unresolved.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

On current main, with a locale whose decimal separator is a comma:

>>> import humanize
>>> humanize.i18n.activate("fr_FR")
>>> humanize.intcomma(1.5)
'1,5'
>>> humanize.naturalsize(1_500_000)
'1.5 Mo'

The same happens for every locale with "," as the decimal separator (de_DE, fr_FR, hu_HU, it_IT, lv, pt_BR). intword() and intcomma() use decimal_separator(), but naturalsize() does not.

#378 mentioned that naturalsize was left untouched as "the one loose end", and #357 got a ~10% CodSpeed regression on test_naturalsize when it tried to fix this.

Proposal: use decimal_separator() in naturalsize(), but skip the extra work when the separator is "." so the default path is not slowed down, and check the result against the existing benchmarks.

Open PRs #403, #457 and #367 also touch naturalsize(). Would you prefer us to wait for them, or go ahead and rebase later?

Lingua principale
Python
Stelle
768
Fork
243
Merge medio
4g 12h
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-humanize/humanize

Tutte le issue di python-humanize/humanize

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.