naturalsize() ignores the locale decimal separator

Offen
#460 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@ekanshul arbeitet bereits daran.

Seit 20.10.2026.

  • #463 von @ekanshul — offen

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
backend

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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?

Vorherrschende Sprache
Python
Sterne
768
Forks
243
Ø Merge
4 T. 12 Std.
Gemergte PRs (30 T.)
19

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python-humanize/humanize

Alle Issues in python-humanize/humanize

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.