diff options
| author | Kasyap Pentamaraju <vpentamaraju@webmd.net> | 2025-11-03 22:57:53 +0530 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-11-07 14:06:42 -0500 |
| commit | 1c7db70e79dce82f50d5958da64ab8e2807a31df (patch) | |
| tree | 46f77c845c3eba08cf57a9b17918d0d68424f432 /django/utils/numberformat.py | |
| parent | 27687475265f88bc0a0bcbfe2ba26da306bbfc20 (diff) | |
Fixed #36705 -- Avoided string concatenation in utils.
Repeated string concatenation performs poorly on PyPy.
Thanks Seokchan Yoon for the report.
Diffstat (limited to 'django/utils/numberformat.py')
| -rw-r--r-- | django/utils/numberformat.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py index cf8b2d219c..f621ff64b4 100644 --- a/django/utils/numberformat.py +++ b/django/utils/numberformat.py @@ -91,15 +91,15 @@ def format( # grouping is a single value intervals = [grouping, 0] active_interval = intervals.pop(0) - int_part_gd = "" + int_part_gd = [] cnt = 0 for digit in int_part[::-1]: if cnt and cnt == active_interval: if intervals: active_interval = intervals.pop(0) or active_interval - int_part_gd += thousand_sep[::-1] + int_part_gd.append(thousand_sep[::-1]) cnt = 0 - int_part_gd += digit + int_part_gd.append(digit) cnt += 1 - int_part = int_part_gd[::-1] + int_part = "".join(int_part_gd)[::-1] return sign + int_part + dec_part |
