summaryrefslogtreecommitdiff
path: root/django/db/backends/utils.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-12-30 18:05:15 +0100
committerGitHub <noreply@github.com>2017-12-30 18:05:15 +0100
commit51a00749e9d1814acfb6bf8732ecd21f18944083 (patch)
treec03edebd5a5263fc1ff622d6fa526a7918f437c9 /django/db/backends/utils.py
parent9bc4d90d1a8c4d1dee54115a0995a7b6fca8635b (diff)
downloaddjango-51a00749e9d1814acfb6bf8732ecd21f18944083.tar.gz
Used Decimal.scaleb() in backends.utils.format_number() and DecimalField.widget_attrs() to improve performance.
Diffstat (limited to 'django/db/backends/utils.py')
-rw-r--r--django/db/backends/utils.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/backends/utils.py b/django/db/backends/utils.py
index f4641e3db8..a574d64562 100644
--- a/django/db/backends/utils.py
+++ b/django/db/backends/utils.py
@@ -236,7 +236,7 @@ def format_number(value, max_digits, decimal_places):
if max_digits is not None:
context.prec = max_digits
if decimal_places is not None:
- value = value.quantize(decimal.Decimal(".1") ** decimal_places, context=context)
+ value = value.quantize(decimal.Decimal(1).scaleb(-decimal_places), context=context)
else:
context.traps[decimal.Rounded] = 1
value = context.create_decimal(value)