Utils: lazy decimal import
decimal is kinda big, there is no noticable difference in performance and the import is unused by webhost's customserver
This commit is contained in:
parent
9bd035a19d
commit
f5e48c850d
2
Utils.py
2
Utils.py
|
@ -11,7 +11,6 @@ import io
|
||||||
import collections
|
import collections
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import decimal
|
|
||||||
from yaml import load, load_all, dump, SafeLoader
|
from yaml import load, load_all, dump, SafeLoader
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -507,6 +506,7 @@ def chaining_prefix(index: int, labels: typing.Tuple[str]) -> str:
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
def format_SI_prefix(value, power=1000, power_labels=("", "k", "M", "G", "T", "P", "E", "Z", "Y")) -> str:
|
def format_SI_prefix(value, power=1000, power_labels=("", "k", "M", "G", "T", "P", "E", "Z", "Y")) -> str:
|
||||||
"""Formats a value into a value + metric/si prefix. More info at https://en.wikipedia.org/wiki/Metric_prefix"""
|
"""Formats a value into a value + metric/si prefix. More info at https://en.wikipedia.org/wiki/Metric_prefix"""
|
||||||
|
import decimal
|
||||||
n = 0
|
n = 0
|
||||||
value = decimal.Decimal(value)
|
value = decimal.Decimal(value)
|
||||||
limit = power - decimal.Decimal("0.005")
|
limit = power - decimal.Decimal("0.005")
|
||||||
|
|
Loading…
Reference in New Issue