naturalsize() ignores the locale decimal separator

Open
#460 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@ekanshul is already working on this.

Since Oct 20, 2026.

  • #463 by @ekanshul — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

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.

Written by the indexing model from the issue text.

Description

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?

Dominant language
Python
Stars
768
Forks
243
Avg merge
4d 12h
Merged PRs (30d)
19

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-humanize/humanize

All issues in python-humanize/humanize

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.